Page 73 - DCAP103_Principle of operating system
P. 73

Principles of Operating Systems



                   Notes         clock interrupt occurs, the interrupt handler checks how much time the current running process
                                 has used. If it has used up its entire time slice, then the CPU scheduling algorithm (in kernel)
                                 picks a different process to run. Each switch of the CPU from one process to another is called
                                 a context switch.
                                 3.2.1 Major Steps of Context Switching

                                    •  The values of the CPU registers are saved in the process table of the process that was
                                      running just before the clock interrupt occurred.

                                    •  The registers are loaded from the process picked by the CPU scheduler to run next.
                                 In  a  multiprogrammed  uniprocessor  computing  system,  context  switches  occur  frequently
                                 enough that all processes appear to be running concurrently. If a process has more than one
                                 thread, the Operating System can use the context switching technique to schedule the threads
                                 so they appear to execute in parallel. This is the case if threads are implemented at the kernel
                                 level. Threads can also be implemented entirely at the user level in run-time libraries. Since in
                                 this case no thread scheduling is provided by the Operating System, it is the responsibility of
                                 the programmer to yield the CPU frequently enough in each thread so all threads in the process
                                 can make progress.
                                 3.2.2 Action of Kernel to Context Switch among Threads

                                 The threads share a lot of resources with other peer threads belonging to the same process so
                                 a context switch among threads for the same process is easy. It involves switch of register set,
                                 the program counter and the stack. It is relatively easy for the kernel to accomplish this task.

                                 3.2.3 Action of Kernel to Context Switch among Processes
                                 Context switches among processes are expensive. Before a process can be switched its process
                                 control block (PCB) must be saved by the operating system. The PCB consists of the following
                                 information:

                                    •  The process state.
                                    •  The program counter, PC.
                                    •  The values of the different registers.

                                    •  The CPU scheduling information for the process.
                                    •  Memory management information regarding the process.

                                    •  Possible accounting information for this process.
                                    •  I/O status information of the process.

                                 When the PCB of the currently executing process is saved the operating system loads the PCB
                                 of the next process that has to be run on CPU. This is a heavy task and it takes a lot of time.



                                                Before  a  process can  be  switched  its  process control block  (PCB)  must  be
                                                saved by the operating system.


                                 3.3 Multi-threading in IDL


                                 ITT-VIS has added support for using threads internally in IDL to accelerate specific numerical
                                 computations on multi-processor systems. Multi-processor capable hardware has finally become



        66                                LOVELY PROFESSIONAL UNIVERSITY
   68   69   70   71   72   73   74   75   76   77   78