Scheduling Flashcards

1
Q

What does Thread Scheduling deal with?

A

Thread scheduling deals with allocating threads to CPUs and deciding how long each thread will execute.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Give a brief descrirtion of a thread when it is in a New State

A

A thread object has been created, but the thread as such does not yet exist because ‘start’ has not been called yet.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Give a brief descrirtion of a thread when it is in a Runnable State

A

After ‘start’ has been called on a thread it moves into the ‘runnable’ state – this is the default state for a thread. Many threads might be in the ‘runnable’ state but only one (per cpu) will actually be executing. (The scheduler determines which threads will actually ‘run’).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Give a brief descrirtion of a thread when it is in a Blocked State

A

If a thread executes a sleep(), wait(), or join() method, or when it is blocked when trying to read data, or when it is waiting for a lock on a synchronized object, it moves into the ‘blocked’ state. When it unblocks, it moves into the runnable state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Give a brief descrirtion of a thread when it is in a Terminated State

A

When a thread’s run() method finished it moves to the terminated state (i.e. the ‘thread’ terminates).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Name atleast one situation where the schedular will run a different thread

A

One of the currently executing threads exits the Runnable state, i.e. it enters the blocked state (via a ‘wait’ or ‘sleep’ or ‘yield’ etc.) or it terminates.

A higher priority thread than one of the currently running threads enters the Runnable state. The lower priority thread is preempted and the higher priority thread is run.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly