|
FALL 2000 Lecture Notes 5: PROCESSOR MANAGEMENT A process is a single instance of an executable program." An interrupt is a hardware signal that suspends execution of a program and calls the interrupt handler." Process control block:Each process is represented by a PCB. The PCB:
Multiprogramming (multitasking) :technique allowing several processes to reside simultaneously in main memory and interleave their execution . Before operating system can schedule jobs, needs to resolve limitations of system:
Good process management strategy may include (notice some of them contradict)
Final decision on which strategy to take rests with system designer. Non-preemptive scheduling policy: A job scheduling strategy in which the job captures the processor and begins execution and runs uninterrupted until it issues an IO request or it is finished. Non-preemptive scheduling algorithms (used in batch systems where CPU time is estimated by the user)
When a new job enters the system, it is added straight onto the queue for the processor. Turnaround time is unpredictable – for example, suppose there are three jobs: Job 1 needs 15 milliseconds CPU time Timeline 1
If all three jobs arrive almost same time, turnaround for Job 1 is 15, Job 2 is 17 and Job 3 is 18, so average turnaround is: (15 + 17 + 18) / 3 = 16.67 If the jobs arrived in a different order results would be
(1 + 3 + 18) / 3 = 7.3 Gives minimum average turnaround - always gives second situations shown for FCFS. Only works when all jobs are available at the same time and CPU estimates are accurate. Most common method in batch systems, but may give slow turnaround to some users. Gives preferential treatment to important jobs. Jobs with the same priority are treated FCFS. Priority could be based on:
Preemptive job scheduling: A process scheduling strategy in which the processing of a job is interrupted and the CPU is transferred to another job. Also called context switching. Preemptive scheduling algorithms
Pre-emptive version of SJN. The processor is allocated to the job closest to completion. Can’t be implemented on interactive system because it requires advance knowledge of required CPU time. For example, if the following four jobs arrive:
Processing will occurs as follows:
Turnaround (14 + 4 + 1 +6) /4 = 6.25 However, the time for context switching is not included in this and it takes valuables CPU time. Preemptive process scheduling algorithm used extensively in interactive systems. Easy to implement and isn’t based on job characteristics, but on time slicing. Goal is to ensure that CPU is equally shared and not monopolized. The size of the time slice is crucial to the performance. Jobs are placed in a queue, FCFS. First job is allocated one time slice. If processing isn’t finished after 1 slice, job is put at end of queue. Example:
If the time slices are 4 cycles, the following will occur:
Turnaround time (20 + 7 +24 +22)/4 = 18.25 If time slice is too big, jobs will run FCFS. If too small, there will be too much context switching. Not really separate type, but hybrid. Can be:
Within the queues, jobs are served FCFS. Much attention has to be paid to "aging" how long job has been waiting. Have to avoid indefinite postponement. INTERRUPTS Interrupts to a process can occur when a process makes an IO request or due to context switching. Interrupts can also occur as a direct result of the job instruction currently being processed, e.g
Interrupts handled by interrupt handler as follows:
PROCESS MANAGEMENT UNDER DOS DOS is a single-user single-task environment. DOS does not support multitasking. However, although two jobs can’s run together, some software programs give that illusion. Both Windows 3.1 and Borland Sidekick for example appear to interrupt the main program, change screen displays, run a couple of programs and then return to the main program. They feel like multitasking, but there is never more than one program in the RUNNING state at the same time. The other programs "sleep". The interrupt handlers allow the parent program to start again after the child has finished. DOS has 256 interrupts and associated handlers and they are accessed via the interrupt vector residing in the lowest byes of RAM. There are three types of DOS interrupt:
When CPU gets a DOS interrupt, it puts onto a stack the code segment register and the instructions pointer register(where the program is stored and at what point in processing ). It also disables the interrupt handler so that no more interrupts can be received till the current one has been handled. CPU uses 8 bit number placed on system bus to get the address of the handler from the vector table. PROCESS MANAGEMENT UNDER WIN NT NT is a preemptive multitasking multithreaded operating system. A process is :
With NT there is a fourth component - a "thread of execution". A thread is the entity that NT kernel schedules as a task. This can be split into several parts called multithreading, allowing several executable segments to execute in parallel with multiple processors. By default, a process contains one thread. A process can have as many threads as there are CPU’s available in the system. It is important to note the NT has inbuilt protection that stops one thread from modifying a global variable independently from another. WIN 95/98 Preemptive multitasking operating system using time slicing (20 milliseconds). In 95/98 threads can share a single CPU. The CPU is switched from one thread to another.
|