Presentation is loading. Please wait.

Presentation is loading. Please wait.

WORKING OF SCHEDULER IN OS

Similar presentations


Presentation on theme: "WORKING OF SCHEDULER IN OS"— Presentation transcript:

1 WORKING OF SCHEDULER IN OS
How does a scheduler work? When / How is it needed ?

2 Suppose a process is executing and Disk interrupt occurs ( say any I/p taken at keyboard ). ( Each I/O device has an entry in Interrupt Descriptor Table which contains the address of its interrupt handler). It maybe any interrupt like time interrupt. Here we consider I/O interrupt After sending interrupt the I/o device is blocked waiting for a reply / confirmation from current executing process that it can be scheduled Interrupt hardware saves the program counter and 2-3 more registers on the current executing process' stack. Now current executing process → Interrupt Handler. Interrupt handler saves all the present register in the process description table. ( Store the process context needed to resume the process execution ). Free the current stack and go to the new stack. Message sent to the I/O device indicating that current executing process' context has been successfully saved and it can be scheduled. I/.o device: blocked → ready state Call to SCHEDULER NOW that uses scheduling algorith to run new process based on nice value ( priority) If scheduled the I/O device is run else it remains in the queue (running state) waiting for scheduler to schedule it

3 EXECUTION OF SYSTEM CALLS IN OS
System calls are special function determined by the OS that are executed by kernels only. They are special functions executed by OS on behalf of user. They are a layer of abstraction between software and hardware. E.g.: create a text file-> create(), open a file-> open().

4 User space 1- Calling program ( C code ) loads the parameters of sys call on the stack of the calling process. Increment stack pointer. What is stack? It stores all functions that have not returned yet! Now actual call to the library procedure that is to be executed by the kernel 3- Library procedure stores the system call to be executed in the register where OS expects it 4- TRAP Kernel Space 5- Execute the system call by calling system call handler that executes by accessing parameters and system call number in the stack and registers respectively. ( Each system call is mapped to the address of its handler ) 6- Check for error after execution. If any error then save value Process Register accordingly, store error code in the errno variable and return -1. Else return the exit code. (What is errno? Special variable that stores the code of the error. Errno is mapped to sys_err_list that contains the description of error) 7- TRAP User Space

5 8- Library routine checks the returned value and returns to calling program accordingly
9- Registers cleared and stack freed. Stack pointer decremented. NOTE: THIS IS GENERAL PROCUDRE FOR MONOLITHIC KERNEL ARCHITECTURE ONLY NOT MICROKERNEL THANK YOU


Download ppt "WORKING OF SCHEDULER IN OS"

Similar presentations


Ads by Google