Presentation is loading. Please wait.

Presentation is loading. Please wait.

Topic 6 : Introduction to Operating Systems L & E: Pages 1-19, 17-29 Tanenbaum: Pages 1-5, 15-16, 50-53.

Similar presentations


Presentation on theme: "Topic 6 : Introduction to Operating Systems L & E: Pages 1-19, 17-29 Tanenbaum: Pages 1-5, 15-16, 50-53."— Presentation transcript:

1 Topic 6 : Introduction to Operating Systems L & E: Pages 1-19, 17-29 Tanenbaum: Pages 1-5, 15-16, 50-53

2 Book Details Reminder: We will use two different books for this course. “Fundamentals of Operating Systems”, A. M. Lister and R. D. Eager, Fifth Edition, Macmillan Computer Science Series, ISBN. 0-333-59848-2, £13.99. “Operating Systems Design and Implementation”, A. S. Tanenbaum, Prentice-Hall International, ISBN. 0-13-630195-9, about £29.99. www.comp.lancs.ac.uk/computing/staff/kc/keiths_teach ing.html

3 Operating Systems Provide a Virtual Machine Hardware Operating System Specific Interface O/S  An OS is responsible for:  Sharing resources  Ensuring optimisation of resources

4 Wrote a minimal dispatcher. Basic idea is to load the program from disk and start it executing. When its finished start executing another one. During its period of execution the program is called a process.

5 Approach for Simple Dispatcher Sit in a loop waiting for a program to be ready to run. Load the specified program from disk into memory. Use base and limit registers to make sure program addresses work. When the program has finished go back to the loop and wait for another to be ready.

6 This Lecture…. Doing many things at the same (or apparently the same) time…

7 Some Simple Definitions Sequential = doing things one at a time. Concurrent = doing things (apparently) at the same time. Parallel = doing things really at the same time.

8 Example Programs Two programs to be run. Begin putline (“1”); putline (“2”); putline (“3”); End. Begin putline (“A”); putline (“B”); putline (“C”); End.

9 Sequential Execution Job One Job Two Output

10 Sequential Execution Job One Job Two Output 1 2 3

11 Sequential Execution Job One Job Two Output 1 2 3 A B C

12 Concurrent Execution Job One Job Two Output

13 Concurrent Execution Job One Job Two Output 1

14 Concurrent Execution Job One Job Two Output 1 A

15 Concurrent Execution Job One Job Two Output 1 A 2

16 Concurrent Execution Job One Job Two Output 1 A 2 B

17 Concurrent Execution Job One Job Two Output 1 A 2 B 3

18 Concurrent Execution Job One Job Two Output 1 A 2 B 3 C

19 Parallel Execution Job One Job Two Output

20 Parallel Execution Job One Job Two Output 1 A

21 Parallel Execution Job One Job Two Output 1 2 A B

22 Parallel Execution Job One Job Two Output 1 2 3 A B C

23 Summary of Execution Patterns Sequential Concurrent Parallel

24 Extending Our Dispatcher to Deal With Concurrency Load programs into different parts of memory. Make each program save its data and where it is when it wants to temporarily stop running (c.f. interrupts). Modify the dispatcher so it can jump to these saved points.

25 Why Multiple Programs? Support multiple tasks by users. Allow tasks to proceed in background. Allow programs to be structured as independent tasks. Support multiple users.

26 The Old Application Program Main Memory Address Machine Language Instruction 2 3 4 5 6 LOAD6 MULT 6 STORE 6 JUMP 0 1 NULL LDBASE #0 1 10

27 The New Application Program Main Memory Address 4 LDA#8 0 1 STB LDBASE #0 3 2 3 JUMP 4 # PC Stored Here @3 12 STPC+2B 13 JUMP0

28 The New Dispatcher Sit in a loop waiting for a program to be ready to run. If it’s a new program load the specified program from disk into memory and jump to the start. If it’s an old program... restore the registers and jump back via stored PC.

29 The New Dispatcher JUMPIDLE STARTIT:LDBASEBASETABLE+ JUMPSUBSAVE_IT IDLE:LDAPTE JNZDISPATCH JUMPIDLE 0 1 2 3 4 5 PTE = 0 Acc = 0 Base = 0 Limit = 0 Index = 0

30 The New Dispatcher DISPATCH:STI LDABASE_TABLE+ JNZ RESTORE_IT JUMPSUBLOADIT LDLIMITLIMITTABLE+ JUMPSTARTIT PTE = 0 Acc = 0 Base = 0 Limit = 0 Index = 0 6 7 8 9 10 11

31 The New Dispatcher SAVE_IT:STAACC_TABLE+ RETURN RESTORE_ITLDAACC_TABLE+ LDLIMITLIMIT_TABLE+ JUMPSTART_IT 12 13 14 15 16 PTE = 0 Acc = 0 Base = 0 Limit = 0 Index = 0

32 Supporting Data Structures BASETABLE:0 0 LIMITTABLE:0 0 ACCTABLE:0 0

33 Demo JUMPIDLE STARTIT:LDBASEBASETABLE+ JUMPSUBSAVE_IT IDLE:LDAPTE JNZDISPATCH JUMPIDLE 0 1 2 3 4 5 PTE = 0 Acc = 0 Base = 0 Limit = 0 Index = 0

34 Demo JUMPIDLE STARTIT:LDBASEBASETABLE+ JUMPSUBSAVE_IT IDLE:LDAPTE JNZDISPATCH JUMPIDLE PTE =1 Acc = 1 Base = 0 Limit = 0 Index = 0 0 1 2 3 4 5

35 Demo JUMPIDLE STARTIT:LDBASEBASETABLE+ JUMPSUBSAVE_IT IDLE:LDAPTE JNZDISPATCH JUMPIDLE PTE = 1 Acc = 1 Base = 0 Limit = 0 Index = 0 0 1 2 3 4 5

36 Demo DISPATCH:STI LDABASE_TABLE+ JNZ RESTORE_IT JUMPSUBLOADIT LDLIMITLIMITTABLE+ JUMPSTARTIT PTE = 1 Acc = 1 Base = 0 Limit = 0 Index = 1 6 7 8 9 10 11

37 Demo DISPATCH:STI LDABASE_TABLE+ JNZ RESTORE_IT JUMPSUBLOADIT LDLIMITLIMITTABLE+ JUMPSTARTIT PTE = 1 Acc = 0 Base = 0 Limit = 0 Index = 1 6 7 8 9 10 11

38 Demo DISPATCH:STI LDABASE_TABLE+ JNZ RESTORE_IT JUMPSUBLOADIT LDLIMITLIMITTABLE+ JUMPSTARTIT PTE = 1 Acc = 0 Base = 0 Limit = 0 Index = 1 6 7 8 9 10 11

39 Demo DISPATCH:STI LDABASE_TABLE+ JNZ RESTORE_IT JUMPSUBLOADIT LDLIMITLIMITTABLE+ JUMPSTARTIT PTE = 1 Acc = 0 Base = 0 Limit = 0 Index = 1 6 7 8 9 10 11 Assume LOADIT finds some space in memory and fixes the base and limit registers accordingly.

40 Supporting Data Structures BASETABLE:0 100 0 LIMITTABLE:0 199 0 ACCTABLE:0 0

41 Demo DISPATCH:STI LDABASE_TABLE+ JNZ RESTORE_IT JUMPSUBLOADIT LDLIMITLIMITTABLE+ JUMPSTARTIT PTE = 1 Acc = 0 Base = 0 Limit = 199 Index = 1 6 7 8 9 10 11

42 Demo DISPATCH:STI LDABASE_TABLE+ JNZ RESTORE_IT JUMPSUBLOADIT LDLIMITLIMITTABLE+ JUMPSTARTIT PTE = 1 Acc = 0 Base = 0 Limit =199 Index =1 6 7 8 9 10 11

43 Demo JUMPIDLE STARTIT:LDBASEBASETABLE+ JUMPSUBSAVE_IT IDLE:LDAPTE JNZDISPATCH JUMPIDLE PTE = 1 Acc = 0 Base = 100 Limit = 199 Index = 1 0 1 2 3 4 5

44 Demo Main Memory Address 104 LDA#8 100 101 STB LDBASE #0 3 102 103 JUMP 4 # PC Stored Here @3 112 STPC+2B 113 JUMP0 PTE =0 Acc = 0 Base = 100 Limit = 199 Index = 1

45 Demo Main Memory Address 104 LDA#8 100 101 STB LDBASE #0 3 102 103 JUMP 4 # PC Stored Here @3 112 STPC+2B 113 JUMP0 PTE = 0 Acc = 8 Base = 100 Limit =199 Index =1

46 Demo Main Memory Address 104 LOAD#8 100 101 STB LDBASE #0 3 102 103 JUMP 4 # PC Stored Here @3 112 STPC+2B 113 JUMP0 PTE = 0 Acc =9 Base = 100 Limit = 199 Index = 1 program instructions leading to it wanting to halt temporarily

47 Demo Main Memory Address 104 LOAD8 100 101 STB LDBASE #0 3 102 103 JUMP 4 # PC Stored Here @3 112 STPC+2B 113 JUMP0 PTE = 0 Acc = 8 Base = 100 Limit = 199 Index = 1 B = 14

48 Demo Main Memory Address 104 LOAD8 100 101 STB LDBASE #0 3 102 103 JUMP 4 # PC Stored Here @3 112 STPC+2B 113 JUMP0 PTE = 0 Acc = 8 Base = 100 Limit = 199 Index = 1 B = 14

49 Demo Main Memory Address 104 LOAD8 100 101 STB LDBASE #0 3 102 103 JUMP 14 # PC Stored Here @3 112 STPC+2B 113 JUMP0 PTE = 0 Acc = 8 Base = 100 Limit = 199 Index = 1 B = 14

50 Demo Main Memory Address 104 LOAD8 100 101 STB LDBASE #0 3 102 103 JUMP 14 # PC Stored Here @3 112 STPC+2B 113 JUMP0 PTE = 0 Acc = 8 Base = 0 Limit = 199 Index = 1 B = 14

51 Demo JUMPIDLE STARTIT:LDBASEBASETABLE+ JUMPSUBSAVE_IT IDLE:LDAPTE JNZDISPATCH JUMPIDLE 0 1 2 3 4 5 PTE = 0 Acc = 8 Base = 0 Limit = 199 Index = 1

52 Demo SAVE_IT:STAACC_TABLE+ RETURN RESTORE_ITLDAACC_TABLE+ LDLIMITLIMIT_TABLE+ JUMPSTART_IT 12 13 14 15 16 PTE = 0 Acc = 8 Base = 0 Limit = 199 Index = 1

53 Supporting Data Structures BASETABLE:0 100 0 LIMITTABLE:0 199 0 ACCTABLE:0 8 0

54 Demo SAVE_IT:STAACC_TABLE+ RETURN RESTORE_ITLDAACC_TABLE+ LDLIMITLIMIT_TABLE+ JUMPSTART_IT PTE =0 Acc = 8 Base = 0 Limit = 199 Index = 1 12 13 14 15 16

55 Demo JUMPIDLE STARTIT:LDBASEBASETABLE+ JUMPSUBSAVE_IT IDLE:LDAPTE JNZDISPATCH JUMPIDLE PTE =0 Acc = 0 Base = 0 Limit = 199 Index = 1 0 1 2 3 4 5

56 Demo JUMPIDLE STARTIT:LDBASEBASETABLE+ JUMPSUBSAVE_IT IDLE:LDAPTE JNZDISPATCH JUMPIDLE PTE = 0 Acc = 0 Base = 0 Limit = 0 Index = 1 0 1 2 3 4 5

57 Demo JUMPIDLE STARTIT:LDBASEBASETABLE+ JUMPSUBSAVE_IT IDLE:LDAPTE JNZDISPATCH JUMPIDLE PTE = 0 Acc = 0 Base = 0 Limit = 0 Index = 1 0 1 2 3 4 5

58 Demo JUMPIDLE STARTIT:LDBASEBASETABLE+ JUMPSUBSAVE_IT IDLE:LDAPTE JNZDISPATCH JUMPIDLE PTE = 1 Acc = 1 Base = 0 Limit = 0 Index = 1 0 1 2 3 4 5

59 Demo JUMPIDLE STARTIT:LDBASEBASETABLE+ JUMPSUBSAVE_IT IDLE:LDAPTE JNZDISPATCH JUMPIDLE PTE =1 Acc = 1 Base = 0 Limit = 0 Index = 1 0 1 2 3 4 5

60 Demo DISPATCH:STI LDABASE_TABLE+ JNZ RESTORE_IT JUMPSUBLOADIT LDLIMITLIMITTABLE+ JUMPSTARTIT PTE =1 Acc = 1 Base = 0 Limit =0 Index = 1 6 7 8 9 10 11

61 Demo DISPATCH:STI LDABASE_TABLE+ JNZ RESTORE_IT JUMPSUBLOADIT LDLIMITLIMITTABLE+ JUMPSTARTIT PTE = 0 Acc = 100 Base = 0 Limit =0 Index = 0 6 7 8 9 10 11

62 Demo DISPATCH:STI LDABASE_TABLE+ JNZ RESTORE_IT JUMPSUBLOADIT LDLIMITLIMITTABLE+ JUMPSTARTIT PTE =1 Acc =100 Base = 0 Limit = 0 Index =1 6 7 8 9 10 11

63 Demo SAVE_IT:STAACC_TABLE+ RETURN RESTORE_ITLDAACC_TABLE+ LDLIMITLIMIT_TABLE+ JUMPSTART_IT 12 13 14 15 16 PTE =1 Acc =8 Base = 0 Limit = 0 Index =1

64 Demo SAVE_IT:STAACC_TABLE+ RETURN RESTORE_ITLDAACC_TABLE+ LDLIMITLIMIT_TABLE+ JUMPSTART_IT PTE =1 Acc =8 Base = 0 Limit = 199 Index =1 12 13 14 15 16

65 Demo SAVE_IT:STAACC_TABLE+ RETURN RESTORE_ITLDAACC_TABLE+ LDLIMITLIMIT_TABLE+ JUMPSTART_IT 12 13 14 15 16 PTE =1 Acc =8 Base = 0 Limit = 199 Index =1

66 Demo JUMPIDLE STARTIT:LDBASEBASETABLE+ JUMPSUBSAVE_IT IDLE:LDAPTE JNZDISPATCH JUMPIDLE 0 1 2 3 4 5 PTE =1 Acc =8 Base = 100 Limit = 199 Index =1

67 Demo Main Memory Address 104 LOAD#8 100 101 STB LDBASE #0 3 102 103 JUMP 14 # PC Stored Here @3 112 STPC+2B 113 JUMP0 PTE =0 Acc =8 Base = 100 Limit = 199 Index =1

68 Demo Main Memory Address 104 LOAD8 100 101 STB LDBASE #0 3 102 103 JUMP 14 # PC Stored Here @3 112 STPC+2B 113 JUMP0 114 PTE =0 Acc =8 Base = 100 Limit = 199 Index =1

69 Whew ! Glad That’s Over

70 Process Context We save two pieces of information: accumulator and PC In practice processes have much more context that needs to be saved. Term process context is used to describe all of the state a process must save to be able to resume execution from the same point.

71 Which Process to Run Question: Why stop a process and change to another during its execution ? Answer: Lots of reasons..... Want to give other processes a chance to run (concurrent execution). The process can’t continue until another process has finished its task. The process is waiting for something to happen (e.g. I/O). An exceptional event has occurred (i.e. an interrupt).

72 The Process State Model The decision on which process to run therefore has to be based on knowing whether the process can be run. During their lifetime processes typically cycle through 3 states Ready Running Blocked

73 The Process State Model.. contd Ready

74 The Process State Model.. contd Ready Running Process is selected to run

75 Either

76 The Process State Model.. contd Ready Running Process is selected to run Process finishes time slice

77 OR

78 The Process State Model.. contd Ready Running Process is selected to run Blocked Process blocks (e.g. I/O)

79 The Process State Model.. contd Ready Running Process is selected to run Blocked Process blocks (e.g. I/O) Blocking operation finishes (e.g. I/O)

80 Summary Described different execution patterns: sequential, concurrent and parallel. Developed a simple dispatcher which can handle concurrent processes. Started to look at why you might want to change between concurrent processes - the process state model.

81 Coming next week Problems with concurrent processing.


Download ppt "Topic 6 : Introduction to Operating Systems L & E: Pages 1-19, 17-29 Tanenbaum: Pages 1-5, 15-16, 50-53."

Similar presentations


Ads by Google