GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  J2EE  >  Java

 Print  |  
Question:  What is the difference between preemptive scheduling and time slicing

Answer: Under preemptive scheduling, the highest priority task executes until it enters the waitingor dead states or a higher priority task comes into existence. Under time slicing, a taskexecutes for a predefined slice of time and then reenters the pool of ready tasks. Thescheduler then determines which task should execute next, based on priority andother factors.


March 03, 2006 05:13:50 #1
 ramu   Member Since: Visitor    Total Comments: N/A 

RE: What is the difference between preemptive scheduli...
 

1.    Pre-emptive Scheduling.

Ways for a thread to leave running state -

·         It can cease to be ready to execute ( by calling a blocking i/o method)

·         It can get pre-empted by a high-priority thread, which becomes ready to execute.

·         It can explicitly call a thread-scheduling method such as wait or suspend.

 

·         Solaris JVM’s are pre-emptive.

·         Windows JVM’s were pre-emptive until Java 1.0.2

 

2.    Time-sliced or Round Robin Scheduling

·         A thread is only allowed to execute for a certain amount of time. After that, it has to contend for the CPU (virtual CPU, JVM) time with other threads.

·         This prevents a high-priority thread mono-policing the CPU.

·         The drawback with this scheduling is – it creates a non-deterministic system – at any point in time, you cannot tell which thread is running and how long it may continue to run.

 

·         Mactinosh JVM’s

·         Windows JVM’s after Java 1.0.2

     

 

Back To Question