Preemptive scheduler,I am really confuse! different definitions!

I search about “preemptive scheduler”, But I really confuse…

http://www.janeg.ca/scjp/threads/scheduling.html

In preemptive scheduling the highest priority thread continues to
run until it dies, waits, or is preempted by a thread of higher priority

But When I read IBM site

http://www.ibm.com/developerworks/library/j-thread.html

Under the preemptive threading model, the OS interrupts threads
at any time, usually after allowing them to run for a period of time
(known as a time-slice)

1-Which one is correct?What is the definition of preemptive scheduling and Non-preemptive scheduling?

http://life.csu.edu.au/java-tut/essential/threads/priority.html

If at any time a thread with a higher priority than all other
Runnable threads becomes Runnable,
the runtime system chooses the new higher-priority
thread for execution. The new thread is said to preempt
the other threads.

2-I think that
It is better to say, " it preempts the resource" Right?

There is a question about this word : “preemptive” for me.

3-I think that the second definition is better and suitcase for “preemptive scheduling”

Because we can say:

The thread preempts the cpu, and other threads can not access it, until it terminates. Right?

4-Of course I am still searching, nights and nights!:smiley:

and tonight, I find something nice!But still I have doubt

In preemptive scheduling we preempt the currently executing process.
In non preemptive we allow the current process to finish its cpu burst time.

http://wiki.answers.com/Q/Two_differences_between_preemptive_and_non_preemptive_scheduling

In fact this is OS that preempts, Isn’t?

5-Time slice is only for preemptive scheduling?

They are both correct. Multiple implementations can and do exist of anything.

Your answer make no sense
Anyway,Other questions?Is there anyone to answer?

Where does it make no sense? The part where both are correct definitions of a Preemptive scheduler?

I agree, there is no one definition of what preemtive scheduling means and each of those definitions is correct in those instances where that definition is the one that was applied.

They are of course also both wrong if the other definition was the one that was used.

So in determining what preemptive scheduling means you need to consider which specific product it is with respect to and then see which of the definitions was the one that the product creators used when setting up their product.

I agree, there is no one definition of what preemtive scheduling means and each of those definitions is correct in those instances where that definition is the one that was applied.

They are of course also both wrong if the other definition was the one that was used.

So in determining what preemptive scheduling means you need to consider which specific product it is with respect to and then see which of the definitions was the one that the product creators used when setting up their product.

Please give about what yo said

Where does it make no sense? The part where both are correct definitions of a Preemptive scheduler?

It makes no sense because there is incoherent.

Let’s read the definitions again:

1-

In preemptive scheduling the highest priority thread continues to
run until it dies, waits, or is preempted by a thread of higher priority

2-

Under the preemptive threading model, the OS interrupts threads
at any time, usually after allowing them to run for a period of time
(known as a time-slice)

run until it dies VS the OS interrupts threads at any time, (as a time-slice)

I see incoherent,

Which one is correct?You are answers just make more complicated this subject for me.Please give me a straight answer

There is no “straight” answers. Both are valid ways, both are correct. Pick the one you like best and use that implementation.

Definition of preempt: Take the place of or have precedence over.

A preemptive scheduler is one where some threads take precedence over others. It interrupts the current thread to run another and return execution to the preempted thread later.

You can define any criteria you want for what threads take precedence over others. It can be a priority assigned by the user, the estimated time the thread will take to run, whether some resource the thread needs is available, etc.

Whatever the criteria, it’s still a preemptive scheduler if the scheduler is stopping a thread to start running another one because it’s deemed more important.

There are many other scheduler designs. A naive scheduler simply runs each thread to completion in the order they’re created. A round robin scheduler runs each thread for an equal amount of time before switching to another, always in the same order until each thread finishes.

All right!

Now I tell my definition, Please tell me is it right or not:

In preemptive scheduling , A thread continues to run on CPU,Until its time slice be finished,or until it dies, waits, or is preempted by a thread of higher priority.We call it preemptive , Because this the time scheduler of OS that decide and control thread and preempt the thread,to allow the thread with higher priority runs.But, even preemptive scheduling tries the thread with higher priority runs on CPU,But if the thread with higher priority, does not finish the job at the time slice,It will go to ready state and another thread will be run.

In Non-preemptive scheduling,There is no time slice, A thread continues until thread finished the job.

Is what I said right?

May you explain more about Non-preemptive,and its main difference with preemptive please?

Wikipedia has a list of common scheduling algorithms:

First of all, I must appreciate you dear Dan,Thanks!

The real difference is who decides when the thread stops running.In preemptive scheduling, the OS can decide that. Without preemptive scheduling, the OS cannot decide that…the thread must yield.without preemptive scheduling, threads with higher priority must wait until the running thread finishes or yields.With preemptive scheduling, the OS may stop the thread and run a different thread.

Four conditions enable the posibility for deadlock:

  • Mutual exclusion: It must not be possible for more than one thread to use a resource at the same time.

-No preemption: It must not be possible to remove a resource from a thread that holds it. Only the thread that holds a resource can give it up…

Then, according to this, deadlock never happened in preemptive system. Right?

Anyone may explain how deadlock happen in preemptive system?