| #### Threads Scheduling In the traditional process model, no scheduling is needed since there is only one thread of control, and whenever the process runs, that thread runs. However, with multiple threads, if there are fewer available processors than the number of threads to be run, some decision must be made as to which thread runs first. This is analogous to the scheduling of processes by the operating system on a timesharing system, except that the threads scheduling is visible to and controllable by the application programmer. (Note that POSIX specifies that scheduling is optional, so systems using their own threads implementations may not include the functionality provided by DCE Threads that is described in this section.) DCE Threads scheduling is built on two basic, interacting mechanisms: · Scheduling priorities · Scheduling policies Each thread has a scheduling priority associated with it. Threads with a higher priority have precedence over threads with a lower priority when scheduling decisions are made. The exact treatment of threads of different priorities depends on the scheduling policy they are running under. DCE Threads offers three scheduling policies: · First-In, First-Out (FIFO) In FIFO scheduling, the thread in the highest priority category that has been waiting the longest to run is scheduled first. It runs until it blocks, then again the thread that has been waiting the longest runs, and so on. Threads in the highest priority level are run in this first-in, first-out manner, then the threads in the next highest priority level are run FIFO, and so on. · Round-Robin (RR) With round-robin scheduling, all of the threads at the highest priority level are given turns running by timeslicing. That is, one thread runs for a period of time, then it is interrupted and another thread runs for a period of time, and so on, until all threads have had a chance. The process is repeated until all threads in that priority are finished or blocked. Then the threads in the next highest priority level are also run round-robin until they are all finished or blocked, and so on. · Default In the default scheduling, each thread is given turns running by timeslicing. Higher priority threads are given longer periods of time to run, but even the lowest priority thread eventually has a chance to run. This is in contrast to FIFO and round-robin scheduling, in which it is possible for higher priority threads to prevent lower priority threads from running at all. ####