Docsity

Operating System Principles Quiz 2: Multi-threading and CPU Scheduling - Prof. Dorian Arno, Quizzes of Operating Systems

Toggle sidebar
bg1
CS 481: Operating System Principles
Spring ’09
Quiz #2
1 Multi-threaded Programming (20 pts)
1.1 Give a scenario in which a multi-threaded program might be slower than its single
threaded equivalent, i.e. both programs do the same amount of work.
1. User-level (many-to-one) multi-threading model will not result in a perfor-
mance speed-up and may be slower due to thread operation overhead.
2. Multi-threading a CPU-bound task (even with kernel threads) on a single
processor may not result in a performance speed-up and may be slower due
to thread operation and context switching overhead.
3. Dividing an inherently sequential task amongst multiple threads will not re-
sult in a performance speed up, and thread operation and context switching
overhead might cause a slow down.
4. Dividing a small task (even if parallelizable) amongst multiple threads may
result in a performance slow down due to thread operation and context
switching overhead might cause a slow down.
1.2 Give a scenario in which a multi-threaded program might be faster than its single threaded
equivalent.
1. Allowing other threads to proceed when some thread(s) are blocked for I/O
or events.
2. Dividing parallel tasks amongst multiple threads on a multiprocessor
1.3 You just got a new job and your tasked with implementing a multi-threaded program.
Your boss does not care about performance but wants the program to run on as many
systems as possible. Of the three multi-threaded programming model we discussed in class,
which do you choose and why?
For portability, the one-to-many (user-level) multithreading model will run on the
most systems since it is implemented completely at user-level and does not require
operating system support.
1.4 Your boss realized that he made a mistake (you thought you were smarter than him, any-
way) and that 90% of his potential customers use the same operating system. He now wants
you to implement the multi-threaded program to be as fast as possible without consideration
for portability. Which model do you choose and why?
For best performance, the many-to-many multithreading model, while more com-
plex, allows threads to run concurrently (on different resources) and one thread
blocking for I/O or an event, does not impede other threads. I also accepted
one-to-one: in this model one blocked thread does not impede others from making
progress.
1
pf3

Partial preview of the text

Download Operating System Principles Quiz 2: Multi-threading and CPU Scheduling - Prof. Dorian Arno and more Quizzes Operating Systems in PDF only on Docsity!

CS 481: Operating System Principles

Spring ’

Quiz

1 Multi-threaded Programming (20 pts)

1.1 Give a scenario in which a multi-threaded program might be slower than its single threaded equivalent, i.e. both programs do the same amount of work.

  1. User-level (many-to-one) multi-threading model will not result in a perfor- mance speed-up and may be slower due to thread operation overhead.
  2. Multi-threading a CPU-bound task (even with kernel threads) on a single processor may not result in a performance speed-up and may be slower due to thread operation and context switching overhead.
  3. Dividing an inherently sequential task amongst multiple threads will not re- sult in a performance speed up, and thread operation and context switching overhead might cause a slow down.
  4. Dividing a small task (even if parallelizable) amongst multiple threads may result in a performance slow down due to thread operation and context switching overhead might cause a slow down.

1.2 Give a scenario in which a multi-threaded program might be faster than its single threaded equivalent.

  1. Allowing other threads to proceed when some thread(s) are blocked for I/O or events.
  2. Dividing parallel tasks amongst multiple threads on a multiprocessor

1.3 You just got a new job and your tasked with implementing a multi-threaded program. Your boss does not care about performance but wants the program to run on as many systems as possible. Of the three multi-threaded programming model we discussed in class, which do you choose and why?

For portability, the one-to-many (user-level) multithreading model will run on the most systems since it is implemented completely at user-level and does not require operating system support.

1.4 Your boss realized that he made a mistake (you thought you were smarter than him, any- way) and that 90% of his potential customers use the same operating system. He now wants you to implement the multi-threaded program to be as fast as possible without consideration for portability. Which model do you choose and why?

For best performance, the many-to-many multithreading model, while more com- plex, allows threads to run concurrently (on different resources) and one thread blocking for I/O or an event, does not impede other threads. I also accepted one-to-one: in this model one blocked thread does not impede others from making progress.

2 CPU Scheduling (25 pts)

2.1 What are some issues to consider when choosing a scheduling policy? (You need at least four to earn full credit.)

  1. job throughput
  2. resource utilization
  3. wait time
  4. response time
  5. turn-around time
  6. job/user importance (priority)
  7. mix of jobs (cpu-bound or I/O-bound)
  8. cpu bursts and time slice

2.2 In general, what is a multi-level feedback queue and how does it work?

A multi-level feedback queue is a scheduling mechanism that uses series of queues with each queue having successively lower priority than the preceeding queue. A job in a lower priority queue cannot run until there are no jobs in any queue with a higher priority. Each queue also has its own scheduling algorithm, and some policy is used to decide when to upgrade or downgrade a process to a higher or lower priority queue.

2.3 CPU-bound jobs need more CPU cycles than I/O-bound processes. Yet, many operating systems give I/O-bound higher CPU scheduling priority than CPU-bound jobs. Why? And are there valid reasons for giving CPU-bound jobs higher CPU scheduling priority than I/O-bound jobs.

I/O-bound jobs are typically given higher priority than CPU-bound jobs for two main reasons:

  1. to decrease the response time for I/O-bound jobs, and
  2. to increase system throughput since I/O-bound jobs will quickly release the CPU and request services from an I/O devices, and the I/O devices can be servicing the request of one or more processes while the CPU can be serving another.

There are situations when you might want certain processes to have absolute pri- ority whether CPU-bound or I/O-bound, for example, important system processes. (Note: I graded this part of the question as a 2 point bonus.)