Page 109 - DCAP103_Principle of operating system
P. 109

Principles of Operating Systems



                   Notes         Priority inversion is often solved by priority inheritance. With priority inheritance, a thread that
                                 holds a lock that is wanted by a thread with a higher priority has its priority temporarily and
                                 silently raised: its new priority becomes the same as the priority of the thread that it is causing
                                 to block. When the thread releases the lock, its priority is lowered to its original value. The
                                 goal of priority inheritance is to allow the high-priority thread to run as soon as possible. It is
                                 a common feature of operating systems, and Java virtual machines running on those operating
                                 systems are subject to it. However, it is not a requirement of the Java specification.

                                 3.8.1 Complex Priorities
                                 The second  case  involves  the  priority  assigned  to  threads  by  the operating system. We
                                 mentioned that Java has 11 priority levels (10 of which are available to developers), but this
                                 is an abstraction of the Java language. Operating systems usually have many more priorities.
                                 More important, though, is that the priority that the operating system assigns to a thread
                                 is a complex formula that takes many pieces of information into account. A simple version
                                 of this formula might be this:
                                 Real Priority = Java Priority + SecondsWaiting For CPU

                                 This type of formula accounts for the length of time that the thread has been waiting for a
                                 CPU. After a sufficient amount of time has passed, a thread with a Java priority of 3 has a
                                 real priority that is higher than a currently running Java thread with a priority of 5. This
                                 gives the priority 3 thread an opportunity to run, even though it has a lower priority than
                                 other unblocked threads.

                                 Complex priorities are advantageous because they help to prevent thread starvation. Without
                                 such a model, a low-priority thread would have to wait for all other high-priority threads to
                                 block before it is given a chance to execute; it is likely that it might have to wait forever. With
                                 complex priorities, it can still run much less often than it is higher-priority peers, but at least
                                 it will run sometimes.
                                 On  the  other  hand,  complex  priorities  mean  that  you  cannot  guarantee  thread  scheduling.  In
                                 particular, you cannot use thread priorities to try and prevent race conditions in data access: a lower-
                                 priority thread can interrupt a higher-priority thread while it is in the process of updating shared
                                 data. You also cannot use thread priorities to ensure a certain order of execution between tasks.

                                                1.  C Program For Round Robin Scheduling Method

                                                2.  C Program For Priority Scheduling Algorithm
                                                3.  C Program for Shortest Job First Scheduling Algorithm




                                                 Applying Process Design Principles


                                          an Madison is a principal in Value Creation partners. He facilitates process
                                          improvement using lean, six sigma, reengineering, and continuous improvement
                                   Dtechniques. Dan is the author of Process Mapping, Process Improvement and Process
                                   Management.

                                   Dan Madison has studied what a business process should look like for fifteen years. He
                                   studied what major corporations did in process improvement that made them successful
                                   and distilled his findings into design principles that anyone can use. He has come up with
                                   38 design principles that apply to all business processes.

                                                                                                       Contd...

        102                               LOVELY PROFESSIONAL UNIVERSITY
   104   105   106   107   108   109   110   111   112   113   114