Chapter 24 Flashcards

1
Q

What will happen if all waiting threads have a lower priority in yield method

A

It resumes original thread execution

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

Does yield method used in cooperative scheduling schemes

A

Yes

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

How we can handle starvation

A
  • Sleep

- Yield

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

What sleep do

A

Sleep method used for delay purpose. It causes the currently executing thread to wait for the time specified and call the second highest priority thread to executive

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

What is the method for yield

A

yield()

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

What is the difference between yield and sleep

A

Sleep use in latest machines and yield is for old machines where processing is not time sliced. In such machines, a thread keep continuously executes until it ends. So then yield comes in handy. It allows another thread to execute but with same priority level.
One more difference is thread moves first to sleeping state and then ready state in sleep method. But moves direct to ready state from running state in yield method.

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

What is ready state of thread

A

A state where thread is ready to execute but not executing

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

What is running state of thread

A

A state where thread is executing

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

Does yield used for pooling

A

Yes

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

What are states of threads

A
  • New
  • Ready
  • Running
  • Dead
  • Blocked (block because of Input/output)
  • Sleep
  • Wait
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is wait and notify methods

A

We can put running thread to wait state by wait method and then it can only be resume by calling notify method.

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

What is join() method

A

A thread can wait for another thread just like callback by using join method. It could happen in real time that a running thread require another thread to complete.

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