SLIDE 1
Linköping University 2011-01-30 Department of Computer and Information Science (IDA) Concurrent programming, Operating systems and Real-time operating systems (TDDI04) 3
Processes and threads assignments (LE: 1,3,5,7,8,9,10,11,13)
- 1. Consider a computer running an mp3 player, an X-window system, a terminal with
bash running top, a clock, and a word-processor. The mp3-player have several things going on, playing music, updating a graphic mixer chart and showing rolling text with title information and playtime remaining. The word processor does spell checking while you write and shows an animated help icon. a) Identify several processes in this system. b) Identify several threads in this system. c) Draw a picture of how the operating system may represent the various processes and threads at a given time. d) How are the threads in your picture related to the processes? Which other process - thread relations may exist? e) What differs between kernel-threads, user-threads and processes? Which data does the OS store about them?
- 2. Which are the purposes and motivations of using operating systems?
- 3. A system starts an IDLE thread during boot, and then a thread BILL. The threads are
implemented according to the following (we count one instruction per line).
IDLE: BILL: ADAM: EVE: while (true) thread_create(ADAM); wait(!EVE); eat(Apple); noop; thread_create(EVE); enjoy(OS X); wake(ADAM); forbid(Apple); invent(MAC); launch(Vista);
The operating system will place the new thread in an appropriate queue when it is created or waiting. The operating system manages thread-switches automatically at random times. Assume now that you are in control of the dice, and the thread queues. a) Show a sequence of events (executed instructions and thread switches) that finish all threads while fulfilling the following two conditions: MAC must be invented before OS X, and OS X must be enjoyed before Apple is forbidden. (The instruction wake(ADAM) will move ADAM to an appropriate queue.) b) Show a different sequence of events that break the conditions (MAC is invented after OS X, and Apple is forbidden before eaten). Show the queue contents after each instruction. c) What can you learn from the example?
- 4. Answer the following regarding processes and threads: