Page 358 - DCAP103_Principle of operating system
P. 358

Unit 12: Processes and Threads in Windows



            semaphore, rather than having one of them create the object and then make duplicate handles   Notes
            for the others, although the latter approach is certainly an option as well.
            The  number  of  Win32  API  calls  dealing  with  processes,  threads,  and  fibers  is  nearly  100,  a
            substantial number of which deal with IPC in one form or another. A summary of the ones
            discussed above as well as some other important ones are given in Figure 12.3.

                Figure 12.3: Some of the Win32 Calls for Managing Processes, Threads, and Fibers


                Win32 API Function         Description

                CreateProcess              Create a new process

                CreateThread               Create a new thread in an existing process

                CreateFiber                Create a new fiber

                ExitProcess                Terminate current process and all its threads

                ExitThread                 Terminate this thread
                ExitFiber                  Terminate this fiber

                SetPriorityClass           Set the priority class for a process

                SetThreadPriority          Set the priority for one thread

                CreateSemaphore            Create a new semaphore

                CreateMutex                Create a new mutex

                OpenSemaphore              Open an existing semaphore
                OpenMutex                  Open an existing mutex

                WaitForSingleObject        Block on a single semaphore, mutex, etc.

                WaitForMultipleObjects     Block on a set of objects whose handles are given

                PulseEvent                 Set an event to signaled then to non-signaled

                ReleaseMutex               Release a mutex to allow another thread to acquire it
                ReleaseSemaphore           Increase the semaphore count by 1

                EnterCriticalSection       Acquire the lock on a critical section

                LeaveCriticalSection       Release the lock on a critical section


            Most of the calls in Figure 12.3 were either discussed above or should be self-explanatory. Again
            note that not all of these are system calls. As we mentioned earlier, Windows 2000 knows nothing
            about fibers. They are entirely implemented in user space. As a consequence, the CreateFiber call
            does its work entirely in user space without making any system calls (unless it has to allocate
            some memory). Many other Win32 calls have this property as well, including EnterCriticalSection
            and LeaveCriticalSection as we noted above.


                                             LOVELY PROFESSIONAL UNIVERSITY                                   351
   353   354   355   356   357   358   359   360   361   362   363