Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

175 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. vwasync.c
  5. Abstract:
  6. ntVdm netWare (Vw) IPX/SPX Functions
  7. Vw: The peoples' network
  8. Contains Asyncrhonous Event Scheduler (thread)
  9. Contents:
  10. VwAesThread
  11. (CheckPendingIpxRequests)
  12. Author:
  13. Richard L Firth (rfirth) 30-Sep-1993
  14. Environment:
  15. User-mode Win32
  16. Revision History:
  17. 30-Sep-1993 rfirth
  18. Created
  19. --*/
  20. #include "vw.h"
  21. #pragma hdrstop
  22. //
  23. // private routine prototypes
  24. //
  25. PRIVATE
  26. VOID
  27. CheckPendingIpxRequests(
  28. VOID
  29. );
  30. //
  31. // global data
  32. //
  33. WORD AesTickCount;
  34. //
  35. // functions
  36. //
  37. #if _MSC_FULL_VER >= 13008827
  38. #pragma warning(push)
  39. #pragma warning(disable:4715) // Not all control paths return (due to infinite loop)
  40. #endif
  41. DWORD
  42. VwAesThread(
  43. IN LPVOID Parameters
  44. )
  45. /*++
  46. Routine Description:
  47. Provides the functionality of the Asynchronous Event Scheduler (AES) in the
  48. Netware world:
  49. - updates the tick count
  50. - completes any matured timer events
  51. - checks any pending requests and schedules the next action
  52. This thread wakes up every PC tick (1/18 second)
  53. Arguments:
  54. Parameters - unused
  55. Return Value:
  56. DWORD
  57. 0
  58. --*/
  59. {
  60. BOOL fOperationPerformed = FALSE ;
  61. static int n = 1 ;
  62. UNREFERENCED_PARAMETER(Parameters);
  63. while (TRUE)
  64. {
  65. //
  66. // we will always yield in this loop to be friendly to others,
  67. // but occasionally we will forcefully do a non zero sleep for
  68. // lower priority threads to run.
  69. //
  70. if ((n % 100) == 0)
  71. {
  72. Sleep(ONE_TICK) ;
  73. n = 1 ;
  74. }
  75. if (!fOperationPerformed && ((n % 4) == 0))
  76. {
  77. Sleep(10) ;
  78. n++ ;
  79. }
  80. else
  81. {
  82. Sleep(0) ;
  83. n++ ;
  84. }
  85. ++AesTickCount;
  86. ScanTimerList();
  87. CheckPendingIpxRequests();
  88. CheckPendingSpxRequests(&fOperationPerformed);
  89. }
  90. return 0; // compiler-pacifier
  91. }
  92. #if _MSC_FULL_VER >= 13008827
  93. #pragma warning(pop)
  94. #endif
  95. PRIVATE
  96. VOID
  97. CheckPendingIpxRequests(
  98. VOID
  99. )
  100. /*++
  101. Routine Description:
  102. Polls the opened, active non-blocking IPX sockets to see if there is anything
  103. to do (data to receive, availability to send, timeouts)
  104. Arguments:
  105. None.
  106. Return Value:
  107. None.
  108. --*/
  109. {
  110. LPSOCKET_INFO pActiveSocket = NULL;
  111. //
  112. // search SOCKET_INFO structures for something to do. Could do select()
  113. // but we have most of the info anyway. We use the BFI filter mechanism
  114. //
  115. while (pActiveSocket = FindActiveSocket(pActiveSocket)) {
  116. if (pActiveSocket->Flags & SOCKET_FLAG_SENDING) {
  117. IpxSendNext(pActiveSocket);
  118. }
  119. if (pActiveSocket->Flags & SOCKET_FLAG_LISTENING) {
  120. IpxReceiveNext(pActiveSocket);
  121. }
  122. }
  123. }