i wanna ask thathow rocesses are sheduled
i have read that the processsheduling ispreemtive that is the high priority process is given preference .
consider asituation where oneprocess has higher priority than the rest . now the high priority process runs for its time slice then thesheduler comes to the ready queue again the hihker priority process would be run and this would continue untill higher priority process
terminates .is it so . in't it going to create starvation for the rest of processes.
CPU Scheduling
Re:CPU Scheduling
You will only see starvation if a high-priority process (better: thread) is always ready to run.
There are two types of scheduling in force in modern operating systems: cooperative and preemptive.
Cooperative scheduling occurs when a thread relinquishes the processor voluntarily. This happens most often when it is waiting for something, e.g. a keypress, a mutex or an IPC request. There's no point running the thread while it's waiting, so it is blocked and other threads are allowed to run. This is most common in a system with mostly user interface and daemon threads.
Preemptive scheduling occurs when a thread has held the CPU for too long when a timer interrupt occurs. The processor is given to another thread without the first thread's consent. This happens if you have a thread doing some lengthy calculations without waiting for I/O.
Starvation will occur if a high-priority thread doesn't give up the CPU. Preemption takes place, but the scheduler continues to choose the high-priority thread because it has the highest priority of any runnable threads (although it could be preempted if, say, the GUI is running a higher priority thread to maintain the mouse pointer which sleeps until you move the mouse).
A common technique to avoid this is to dynamically change threads' priorities depending on how long they have held the CPU (i.e. the length of their timeslice). At the start of its timeslice, the thread has a high static priority and a zero dynamic priority; its effective priority is static - dynamic. At the end of the first quantum the scheduler cuts in and sees that it is the highest-priority thread ready to run. Since it is already running, the scheduler increments it dynamic priority and runs it again. Next time, the scheduler increments its dynamic priority again and continues to run it. Eventually, the thread's effective priority is less than the priority of the next lowest thread and a switch occurs. The first thread is moved down the queue while other threads are allowed to run, and its dynamic priority is reset the next time it is scheduled.
There are two types of scheduling in force in modern operating systems: cooperative and preemptive.
Cooperative scheduling occurs when a thread relinquishes the processor voluntarily. This happens most often when it is waiting for something, e.g. a keypress, a mutex or an IPC request. There's no point running the thread while it's waiting, so it is blocked and other threads are allowed to run. This is most common in a system with mostly user interface and daemon threads.
Preemptive scheduling occurs when a thread has held the CPU for too long when a timer interrupt occurs. The processor is given to another thread without the first thread's consent. This happens if you have a thread doing some lengthy calculations without waiting for I/O.
Starvation will occur if a high-priority thread doesn't give up the CPU. Preemption takes place, but the scheduler continues to choose the high-priority thread because it has the highest priority of any runnable threads (although it could be preempted if, say, the GUI is running a higher priority thread to maintain the mouse pointer which sleeps until you move the mouse).
A common technique to avoid this is to dynamically change threads' priorities depending on how long they have held the CPU (i.e. the length of their timeslice). At the start of its timeslice, the thread has a high static priority and a zero dynamic priority; its effective priority is static - dynamic. At the end of the first quantum the scheduler cuts in and sees that it is the highest-priority thread ready to run. Since it is already running, the scheduler increments it dynamic priority and runs it again. Next time, the scheduler increments its dynamic priority again and continues to run it. Eventually, the thread's effective priority is less than the priority of the next lowest thread and a switch occurs. The first thread is moved down the queue while other threads are allowed to run, and its dynamic priority is reset the next time it is scheduled.