tinker the saga continues
play

Tinker: The Saga Continues PC 03 0 A B 0 IR OUTPUT N 1 AC 001 - PowerPoint PPT Presentation

When last we left our heroine CPU Registers Process A Process B Process C Run Queue Tinker: The Saga Continues PC 03 0 A B 0 IR OUTPUT N 1 AC 001 Mode: USER Main Memory


  1. When last we left our heroine CPU Registers � Process A � Process B � Process C � Run Queue � Tinker: The Saga Continues PC 03 � 0 � A � B � 0 � IR OUTPUT N � 1 � AC 001 � Mode: USER � � Main Memory � Interruptions and Communications Tinker operating system kernel � (00) -001 � (10) � (20) � C0: � (30) 000 � (01) DEQUEUE PID � (11) � (21) � PID: � (31) C � SCHED: � (02) LOAD PID � (12) � (22) � LPID: � (32) � IADDR: � (03) JUMPE SCHED � (13) � (23) � (33) � IVAL: � (04) LOAD C0 � (14) � (24) � (34) � (05) STORE LPID � (15) � (25) � IPID: � (35) 000 � (06) RSTATE PID � (16) � (26) � ACSAV: � (36) � (07) RTI � (17) � (27) � � (37) � (08) � (18) � (28) � (38) � (09) � (19) � (29) � (39) � CS240 Computer Organization Page � Page � Page � Page � Page � Page � table A � table B � table C � frame � frame � frame � Department of Computer Science (40) -000 � (50) +100 � (60) +070 � (70) � (80) � (90) � Wellesley College (41) � (51) � (61) � (71) LOAD N <LOOP � (81) 001 <N � (91) � (42) � (52) � (62) � (72) OUTPUT N � (82) 001 <ONE � (92) � (43) � (53) � (63) � (73) ADD ONE � (83) � (93) � (44) � (54) � (64) � (74) STORE N � (84) � (94) � (45) -050 � (55) -150 � (65) +080 � (75) JUMP LOOP � (85) � (95) � (46) � (56) � (66) � (76) HALT � (86) � (96) � (47) � (57) � (67) � (77) � (87) � (97) � (48) +000 � (58) +000 � (68) +000 � (78) � (88) � (98) � (49) -001 � (59) -001 � (69) -001 � (79) � (89) � OS Tink Continued (99) � 27-2 In for the long haul? On-line storage -- patience.toy � � � � � �� Tinker ordinarily executes instructions sequentially. However, in a o -- Counts to infinity � �� multiprocessing environment, the OS sometimes needs to step in.* LOOP: � LOAD N � � � -- print N to I/O device � These situations are handled by interrupts or traps consisting of o � � OUTPUT N � � -- AC <- N � transfers to specific addresses in the operating system kernel. � � ADD � ONE � � -- AC <- N + 1 � �� Pre-interrupt PC � � STORE � N � � -- store result in N � � � JUMP � LOOP � � -- go back for more � � � HALT � � � -- and stop � (00) � � -- program variables and constants � � �� N: � 000 � � -- label a location for N �� + = kernel mode - = user mode ONE: � 001 � � -- Constant 1 � To get back from an interrupt, the system must have both the old o PC and the previous mode. In Tinker, address 00 holds both values. *Why? OS Tink Continued 27-3 OS Tink Continued 27-4 1 ¡

  2. Good night moon Stop talking while I’m interrupting A quantum interrupt is used to ensure that no process dominates o When interrupts occur from user mode, the current process is o the machine. put to sleep and the active context switches to another process. When a clock interrupt occurs, the hardware suspends the o The operating system saves the current AC plus the pre-interrupt o current process by storing its PC and mode in address 00 and PC and previous mode to the user process so that the previous traps to CLOCK. process can be restarted later.* (08) � CLOCK: � STORE � ACSAV � � -- save user's AC � Process (60) +070 � (09) � � LOAD � LPID � � -- recover last ID � Pre-interrupt PC page table (61) � (10) � � SUB � PID � � -- same as current one? � (62) � (11) � � JUMPE � SLEEP � � -- if so, nite nite � (63) � (12) � ELSE: � LOAD � PID � � -- copy current ID � (64) � (00) � - � 0 � 0 � 4 � + � 3 � 3 � 7 � (65) +080 � (13) � � STORE � LPID � � -- into LPID for next time � (66) � (14) � RESUME: LOAD ACSAV � � -- restore AC � Pre-interrupt AC + = kernel mode (67) � (15) � � RTI � � � -- and resume process � - = user mode (68) +337 � (16) � SLEEP: � LOAD ACSAVE � � -- recover state � (69) -004 � (17) � DISMS: � SSTATE PID � � -- save state � (18) � � ENQUEUE PID � � -- put on run queue � *These values are stored in (and restored from) words 8 and 9 of the per-process page table using the SSTATE (and RSTATE) kernel instructions. (19) � � JUMP SCHED � � -- and get next process � OS Tink Continued 27-5 OS Tink Continued 27-6 � Patience soldiers on and on and on ... Quantum interrupt (the second time around) CPU Registers � Process A � Process B � Process C � Run Queue � CPU Registers � Process A � Process B � Process C � Run Queue � PC 03 � 0 � A � PC 08 � 0 � A � B � 0 � B � 0 � IR OUTPUT N � 1 � IR INPUT N � 1 � 2 � 2 � AC 002 � AC 002 � Mode: USER � Mode: KERNEL � � � Main Memory � Main Memory � Tinker operating system kernel � Tinker operating system kernel � (00) -001 � (10) SUB PID � (20) � C0: � (30) 000 � (00) -003 � (10) SUB PID � (20) � C0: � (30) 000 � (01) DEQUEUE PID � (11) JUMPE SLEEP � (21) � PID: � (31) C � (01) DEQUEUE PID � (11) JUMPE SLEEP � (21) � PID: � (31) C � SCHED: � SCHED: � (02) LOAD PID � ELSE: � (12) LOAD PID � (22) � LPID: � (32) C � (02) LOAD PID � ELSE: � (12) LOAD PID � (22) � LPID: � (32) C � IADDR: � IADDR: � (03) JUMPE SCHED � (13) STORE LPID � (23) � (33) � (03) JUMPE SCHED � (13) STORE LPID � (23) � (33) � IVAL: � IVAL: � (04) LOAD C0 � RESUME: � (14) LOAD ACSAV � (24) � (34) � (04) LOAD C0 � RESUME: � (14) LOAD ACSAV � (24) � (34) � (05) STORE LPID � (15) RTI � (25) � IPID: � (35) � (05) STORE LPID � (15) RTI � (25) � IPID: � (35) � (06) RSTATE PID � (16) LOAD ACSAV � (26) � ACSAV: � (36) � (06) RSTATE PID � (16) LOAD ACSAV � (26) � ACSAV: � (36) � SLEEP: � SLEEP: � (07) RTI � (17) SSTATE PID � (27) � � (37) � (07) RTI � (17) SSTATE PID � (27) � � (37) � DISMS: � DISMS: � (08) STORE ACSAV � (18) ENQUEUE PID � (28) � (38) � (08) STORE ACSAV � (18) ENQUEUE PID � (28) � (38) � CLOCK: � CLOCK: � (09) LOAD LPID � (19) JUMP SCHED � (29) � (39) � (09) LOAD LPID � (19) JUMP SCHED � (29) � (39) � Page � Page � Page � Page � Page � Page � Page � Page � Page � Page � Page � Page � table A � table B � table C � frame � frame � frame � table A � table B � table C � frame � frame � frame � (40) -000 � (50) -100 � (60) +070 � (70) � (80) � (90) � (40) -000 � (50) -100 � (60) +070 � (70) � (80) � (90) � (41) � (51) � (61) � (71) LOAD N <LOOP � (81) 002 <N � (91) � (41) � (51) � (61) � (71) LOAD N <LOOP � (81) 002 <N � (91) � (42) � (52) � (62) � (72) OUTPUT N � (82) 001 <ONE � (92) � (42) � (52) � (62) � (72) OUTPUT N � (82) 001 <ONE � (92) � (43) � (53) � (63) � (73) ADD ONE � (83) � (93) � (43) � (53) � (63) � (73) ADD ONE � (83) � (93) � (44) � (54) � (64) � (74) STORE N � (84) � (94) � (44) � (54) � (64) � (74) STORE N � (84) � (94) � (45) -050 � (55) -150 � (65) +080 � (75) JUMP LOOP � (85) � (95) � (45) -050 � (55) -150 � (65) +080 � (75) JUMP LOOP � (85) � (95) � (46) � (56) � (66) � (76) HALT � (86) � (96) � (46) � (56) � (66) � (76) HALT � (86) � (96) � (47) � (57) � (67) � (77) � (87) � (97) � (47) � (57) � (67) � (77) � (87) � (97) � (48) +000 � (58) +000 � (68) +000 � (78) � (88) � (98) � (48) +000 � (58) +000 � (68) +000 � (78) � (88) � (98) � (49) -001 � (59) -001 � (69) -001 � (79) � (89) � OS Tink Continued (99) � 27-7 (49) -001 � (59) -001 � (69) -001 � (79) � (89) � OS Tink Continued (99) � 27-8 2 ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend