input/outputxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1...
TRANSCRIPT
![Page 1: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/1.jpg)
3INPUT/OUTPUT
3.1 PRINCIPLESOF I/O HARDWARE
3.2 PRINCIPLESOF I/O SOFTWARE
3.3 DEADLOCKS
3.4 OVERVIEW OF I/O IN MINIX
3.5 BLOCK DEVICESIN MINIX
3.6 RAM DISKS
3.7 DISKS
3.8 CLOCKS
3.9 TERMINALS
3.10 THE SYSTEMTASK IN MINIX
![Page 2: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/2.jpg)
Controller-device interface
Disk drives Printer
System bus
Memory Disk controller
Printer controller
Other controllersCPU
Figure 3-1. A model for connectingthe CPU, memory,con-trollers,andI/O devices.
![Page 3: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/3.jpg)
� �������������������������������������������������������������������������������������������������������������������������������I/O controller I/O address Hardware IRQ Interrupt vector� �������������������������������������������������������������������������������������������������������������������������������
Clock 040 – 043 0 8� �������������������������������������������������������������������������������������������������������������������������������Keyboard 060 – 063 1 9� �������������������������������������������������������������������������������������������������������������������������������Hard disk 1F0 – 1F7 14 118� �������������������������������������������������������������������������������������������������������������������������������Secondary RS232 2F8 – 2FF 3 11� �������������������������������������������������������������������������������������������������������������������������������Printer 378 – 37F 7 15� �������������������������������������������������������������������������������������������������������������������������������Floppy disk 3F0 – 3F7 6 14� �������������������������������������������������������������������������������������������������������������������������������Primary RS232 3F8 – 3FF 4 12� �������������������������������������������������������������������������������������������������������������������������������������������������������
������������������������
������������������������
������������������������
������������������������
Figure 3-2. Someexamplesof controllers,their I/O addresses,their hardwareinterrupt lines, and their interrupt vectorson atypical PCrunningMS-DOS.
![Page 4: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/4.jpg)
CPU MemoryDisk
controller
System bus
Count
Drive
Buffer
DMA registers
Memory address Count
Figure 3-3. A DMA transferis doneentirelyby thecontroller.
![Page 5: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/5.jpg)
(a)
07
34
1
2
6
5
(b)
07
52
4
1
3
6
(c)
05
14
3
6
2
7
Figure 3-4. (a) No interleaving. (b) Single interleaving. (c)Doubleinterleaving.
![Page 6: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/6.jpg)
� �������������������������������������������������������������������������������Uniform interfacing for device drivers� �������������������������������������������������������������������������������Device naming� �������������������������������������������������������������������������������Device protection� �������������������������������������������������������������������������������Providing a device-independent block size� �������������������������������������������������������������������������������Buffering� �������������������������������������������������������������������������������Storage allocation on block devices� �������������������������������������������������������������������������������Allocating and releasing dedicated devices� �������������������������������������������������������������������������������Error reporting� �������������������������������������������������������������������������������������������������������
������������������������
Figure 3-5. Functionsof thedevice-independentI/O software.
![Page 7: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/7.jpg)
I/O request
LayerI/O reply I/O functions
Make I/O call; format I/O; spooling
Naming, protection, blocking, buffering, allocation
Set up device registers; check status
Wake up driver when I/O completed
Perform I/O operation
User processes
Device-independent software
Device drivers
Interrupt handlers
Hardware
Figure 3-6. Layersof theI/O systemandthemainfunctionsof eachlayer.
![Page 8: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/8.jpg)
(a)�
(b)�
(c)�T U
�D
C�S
�B
A
R
Figure 3-7. Resourceallocation graphs. (a) Holding a re-source.(b) Requestinga resource.(c) Deadlock.
![Page 9: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/9.jpg)
(j)
A Request R Request S Release R Release S
B Request S Request T Release S Release T
C Request T Request R Release T Release R
1. A requests R 2. B requests S 3. C requests T 4. A requests S 5. B requests T 6. C requests R deadlock
1. A requests R 2. C requests T 3. A requests S 4. C requests R 5. A releases R 6. A releases S no deadlock
A
R
B
S
C
T
(i)
A
R
B
S
C
T
(h)
A�R
B
S
C
T
(g)
A
R
B
S
C
T
(f)
A
R
B
S
C
T
(e)(d)
(c)(b)(a)
A
R
B
S
C
T
(q)
A
R
B
S
C
T
(p)
A
R
B
S
C
T
(o)
A
R
B
S
C
T
(n)
A
R
B
S
C
T
(m)
A
R
B
S
C
T
(l)(k)
A�R
B
S
C
T
Figure 3-8. An exampleof howdeadlockoccursandhow it canbeavoided.
![Page 10: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/10.jpg)
(a) (b)
1. CD-ROM 2. Printer 3. Plotter 4. Tape drive 5. Robot arm
A�i
B
j
Figure 3-9. (a) Numericallyorderedresources.(b) A resourcegraph.
![Page 11: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/11.jpg)
� �������������������������������������������������������������������������������������������Condition Approach� �������������������������������������������������������������������������������������������
Mutual exclusion Spool everything� �������������������������������������������������������������������������������������������Hold and wait Request all resources initially� �������������������������������������������������������������������������������������������No preemption Take resources away� �������������������������������������������������������������������������������������������Circular wait Order resources numerically� ����������������������������������������������������������������������������������������������������������
���������������
���������������
Figure 3-10. Summaryof approachesto deadlockprevention.
![Page 12: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/12.jpg)
Andy
Name
Used Maximum
Barbara
Marvin
Suzanne
Available: 10
(a)
0
0
0
0
6
5
4
7
Andy
Name
Used Maximum
Barbara
Marvin
Suzanne
Available: 2
(b)
1
1
2
4
6
5
4
7
Andy
Name
Used Maximum
Barbara
Marvin
Suzanne
Available: 1
(c)
1
2
2
4
6
5
4
7
Figure 3-11. Three resourceallocation states: (a) Safe. (b)Safe.(c) Unsafe.
![Page 13: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/13.jpg)
Plotter
Printer
Printer
Plotter
B
A
u (Both processes finished)
p q
r
s
t
I8
I7
I6
I5
I4I3I2I1
���
Figure 3-12. Two processresourcetrajectories.
![Page 14: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/14.jpg)
Proce
ssTa
pe d
rives
Plotte
rsPrin
ters
CD-RO
MS
A
B
C �D
E
3 0 �1
1
0� 0
�1
1
1
0� 1
0 �1
0 �0� 1
0 �0 �1
0� E = (6342)
P = (5322) A�
= (1020)
Resources assigned
Proce
ssTa
pe d
rives
Plotte
rsPrin
ters
CD-RO
MS
A
B
C �D
E
1
0 �3 0 �2
1
1
1
0 �1
0 �1
0 �1
1
0 �2
0 �0 �0�
Resources still needed
Figure 3-13. Thebanker’salgorithmwith multiple resources.
![Page 15: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/15.jpg)
File system
User process
Device driver
Processes
Process-structured system Monolithic system
(a) (b)
A process1
4
2 3
1–4 are request and reply messages between three independent processes.
The user-space part calls the kernel-space part by trapping. The file system calls the device driver as a procedure. The entire operating system is part of each process
User- space part
File system
Device driver
User space
Kernel space
Figure 3-14. Two waysof structuringuser-systemcommunication.
![Page 16: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/16.jpg)
� �����������������������������������������������������������������������������������������������������������������Requests� �����������������������������������������������������������������������������������������������������������������
Field Type Meaning� �����������������������������������������������������������������������������������������������������������������m.m� type int Operation requested� �����������������������������������������������������������������������������������������������������������������m.DEVICE int Minor device to use� �����������������������������������������������������������������������������������������������������������������m.PROC � NR int Process requesting the I/O� �����������������������������������������������������������������������������������������������������������������m.COUNT int Byte count or ioctl code� �����������������������������������������������������������������������������������������������������������������m.POSITION long Position on device� �����������������������������������������������������������������������������������������������������������������m.ADDRESS char* Address within requesting process� ��������������������������������������������������������������������������������������������������������������������������
����������� ��������� ���������
��� �����������������������������������������������������������������������������������������������������������������������
Replies� �����������������������������������������������������������������������������������������������������������������������Field Type Meaning� �����������������������������������������������������������������������������������������������������������������������m.m � type int Always TASK� REPLY� �����������������������������������������������������������������������������������������������������������������������m.REP � PROC� NR int Same as PROC� NR in request� �����������������������������������������������������������������������������������������������������������������������m.REP � STATUS int Bytes transferred or error number� ������������������������������������������������������������������������������������������������������������������������������ ������ ������ �������
Figure 3-15. Fieldsof the messagessentby the file systemtotheblock devicedriversandfields of therepliessentback.
![Page 17: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/17.jpg)
message mess; /* message buffer */
void io� task() {initialize(); /* only done once, during system init. */while (TRUE) {
receive(ANY, &mess);/* wait for a request for work */caller = mess.source;/* process from whom message came */switch(mess.type) {
case READ: rcode = dev� read(&mess); break;case WRITE: rcode = dev� write(&mess); break;/* Other cases go here, including OPEN, CLOSE, and IOCTL */default: rcode = ERROR;
}mess.type = TASK� REPLY;mess.status = rcode; /* result code */send(caller, &mess); /* send reply message back to caller */
}}
Figure 3-16. Outlineof themainprocedureof anI/O task.
![Page 18: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/18.jpg)
message mess; /* message buffer */
void shared � io � task(struct driver � table *entry � points) {/* initialization is done by each task before calling this */
while (TRUE) {receive(ANY, &mess);caller = mess.source;switch(mess.type) {
case READ: rcode = (*entry � points� >dev � read)(&mess); break;case WRITE: rcode = (*entry � points� >dev � write)(&mess); break;/* Other cases go here, including OPEN, CLOSE, and IOCTL */default: rcode = ERROR;
}mess.type = TASK � REPLY;mess.status = rcode; /* result code */send(caller, &mess);
}}
Figure 3-17. A sharedI/O taskmainprocedureusingindirectcalls.
![Page 19: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/19.jpg)
User programs
RAM disk�
RAM disk block 1
Main Memory (RAM)
Read and writes of RAM block 0 use this memory
Operating �system� …
Figure 3-18. A RAM disk.
![Page 20: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/20.jpg)
� �����������������������������������������������������������������������������������������������������������������������������������������������������Parameter IBM 360-KB floppy disk WD 540-MB hard disk� �����������������������������������������������������������������������������������������������������������������������������������������������������
Number of cylinders 40 1048� �����������������������������������������������������������������������������������������������������������������������������������������������������Tracks per cylinder 2 4� �����������������������������������������������������������������������������������������������������������������������������������������������������Sectors per track 9 252� �����������������������������������������������������������������������������������������������������������������������������������������������������Sectors per disk 720 1056384� �����������������������������������������������������������������������������������������������������������������������������������������������������Bytes per sector 512 512� �����������������������������������������������������������������������������������������������������������������������������������������������������Bytes per disk 368640 540868608� �����������������������������������������������������������������������������������������������������������������������������������������������������Seek time (adjacent cylinders) 6 msec 4 msec� �����������������������������������������������������������������������������������������������������������������������������������������������������Seek time (average case) 77 msec 11 msec� �����������������������������������������������������������������������������������������������������������������������������������������������������Rotation time 200 msec 13 msec� �����������������������������������������������������������������������������������������������������������������������������������������������������Motor stop/start time 250 msec 9 sec� �����������������������������������������������������������������������������������������������������������������������������������������������������Time to transfer 1 sector 22 msec 53 µsec� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������������
������������������������
������������������������
Figure 3-19. Disk parametersfor theoriginal IBM PC360-KBfloppy disk anda WesternDigital WD AC2540540-MB harddisk.
![Page 21: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/21.jpg)
Initial position
Pending requests
Sequence of seeks
Cylinder
X X X X X X X
0 5 10 15 20 25 30 35
Tim
e
Figure 3-20. ShortestSeekFirst (SSF)disk schedulingalgorithm.
![Page 22: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/22.jpg)
Initial position
Cylinder
X X X X X X X
0 5 10 15 20 25 30 35
Tim
e Sequence of seeks
Figure 3-21. Theelevatoralgorithmfor schedulingdisk requests.
![Page 23: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/23.jpg)
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �Register Read Function Write Function� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
0 Data Data� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �1 Error Write Precompensation� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �2 Sector Count Sector Count� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �3 Sector Number (0-7) Sector Number (0-7)� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �4 Cylinder Low (8-15) Cylinder Low (8-15)� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �5 Cylinder High (16-23) Cylinder High (16-23)� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �6 Select Drive/Head (24-27) Select Drive/Head (24-27)� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �7 Status Command� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �������������� ������������� ������������� �������������
(a)� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �7 6 5 4 3 2 1 0� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �1 LBA 1 D HS3 HS2 HS1 HS0� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � ���� ��� ��� ��� ��� ��� ��� ��� ���
LBA: 0 = Cylinder/Head/Sector Mode1 = Logical Block Addressing Mode
D: 0 = master drive1 = slave drive
HSn: CHS mode: Head Select in CHS modeLBA mode: Block select bits 24 - 27
(b)
Figure 3-22. (a) The control registersof an IDE hard diskcontroller.The numbersin parenthesesarethe bits of the logi-cal block addressselectedby eachregisterin LBA mode. (b)Thefields of theSelectDrive/Headregister.
![Page 24: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/24.jpg)
Crystal oscillator
Counter is decremented at each pulse
Holding register is used to load the counter
Figure 3-23. A programmableclock.
![Page 25: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/25.jpg)
(a) (b) (c)
Time of day in ticks
Time of day in seconds
Counter in ticks
System boot time in seconds
Number of ticks in current second
64 bits 32 bits 32 bits
Figure 3-24. Threewaysto maintainthetime of day.
![Page 26: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/26.jpg)
Current time�
Next signal
Clock �header
3�
4�
6�
2
1 X!4200 3
�Figure 3-25. Simulatingmultiple timerswith a singleclock.
![Page 27: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/27.jpg)
� ���������������������������������������������������������������������������������������������������������������������������������������������Service Access Response Clients� ���������������������������������������������������������������������������������������������������������������������������������������������
Gettime System call Message Any process� ���������������������������������������������������������������������������������������������������������������������������������������������Uptime System call Message Any process� ���������������������������������������������������������������������������������������������������������������������������������������������Uptime Function call Function value Kernel or task� ���������������������������������������������������������������������������������������������������������������������������������������������Alarm System call Signal Any process� ���������������������������������������������������������������������������������������������������������������������������������������������Alarm System call Watchdog activation Task� ���������������������������������������������������������������������������������������������������������������������������������������������Synchronous alarm System call Message Server process� ���������������������������������������������������������������������������������������������������������������������������������������������Milli" delay Function call Busy wait Kernel or task� ���������������������������������������������������������������������������������������������������������������������������������������������Milli" elapsed Function call Function value Kernel or task� ���������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������
������������������
������������������
������������������
Figure 3-26. The clock code supports a number of time-relatedservices.
![Page 28: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/28.jpg)
RS-232 interface
Network interface
Memory-mapped interface
Terminals
X terminalCharacter oriented
Bit oriented
Glass tty
Intelligent ter#
minal
Figure 3-27. Terminaltypes.
![Page 29: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/29.jpg)
CPU$
Memor%
y
Bus& Video RAM
card'Video (
controller' Monitor%
Analog )video signal (e*
.g., 16 MHz)
P+
arallel por, t
K-
eyboard
Figure 3-28. Memory-mappedterminalswrite directly into videoRAM.
![Page 30: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/30.jpg)
… × 3 × 2 × 1 × 0
160 characters
(a).
Video RAM
0/
×B00A0
RAM address
0/
×B0000
80 characters0
(a).
Screen1
A2
B3
C4
D 5
0/
126
37
25 lines6
… × D × C × B × A
Figure 3-29. (a) A video RAM image for the IBM mono-chromedisplay. (b) The correspondingscreen. The ×s areat-tributebytes.
![Page 31: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/31.jpg)
RS-232 interface
card8Computer9
T:erminal
CPU9
MemoryReceive line
Bus;
UART UART
T:
ransmit line
Figure 3-30. An RS-232terminal communicateswith a com-puterover a communicationline, onebit at a time. The com-puterandtheterminalarecompletelyindependent.
![Page 32: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/32.jpg)
Monitor
Network
X client process
Window manager
WindowRemote host
Keyboard
X server process
Mouse
X terminal
X terminal’s processor
QEWEQ asdsd
QEWEQ asdsd
QEWEQ asdsd<
Figure 3-31. Clientsandserversin theM.I.T. X WindowSystem.
![Page 33: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/33.jpg)
(a) (b)
Terminal data structure
Terminal data structure
Terminal
Terminal
Central buffer pool
0 Buffer area for
terminal 0
1 Buffer area for
terminal 1
0
1
2
3
Figure 3-32. (a) Centralbuffer pool. (b) Dedicatedbuffer for eachterminal.
![Page 34: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/34.jpg)
� ���������������������������������������������������������������������������������������������������������������������Character POSIX name Comment� ���������������������������������������������������������������������������������������������������������������������CTRL-D EOF End of file� ���������������������������������������������������������������������������������������������������������������������
EOL End of line (undefined)� ���������������������������������������������������������������������������������������������������������������������CTRL-H ERASE Backspace one character� ���������������������������������������������������������������������������������������������������������������������DEL INTR Interrupt process (SIGINT)� ���������������������������������������������������������������������������������������������������������������������CTRL-U KILL Erase entire line being typed� ���������������������������������������������������������������������������������������������������������������������CTRL-\ QUIT Force core dump (SIGQUIT)� ���������������������������������������������������������������������������������������������������������������������CTRL-Q START Start output� ���������������������������������������������������������������������������������������������������������������������CTRL-S STOP Stop output� ���������������������������������������������������������������������������������������������������������������������CTRL-R REPRINT Redisplay input (MINIX extension)� ���������������������������������������������������������������������������������������������������������������������CTRL-V LNEXT Literal next (MINIX extension)� ���������������������������������������������������������������������������������������������������������������������CTRL-O DISCARD Discard output (MINIX extension)� ���������������������������������������������������������������������������������������������������������������������CTRL-M CR Carriage return (unchangeable)� ���������������������������������������������������������������������������������������������������������������������CTRL-J NL Linefeed (unchangeable)� �������������������������������������������������������������������������������������������������������������������������������������������������
����������������������������
����������������������������
����������������������������
Figure 3-33. Charactersthatarehandledspeciallyin canonicalmode.
![Page 35: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/35.jpg)
struct termios {tcflag = t c = iflag; /* input modes */tcflag = t c = oflag; /* output modes */tcflag = t c = cflag; /* control modes */tcflag = t c = lflag; /* local modes */speed = t c = ispeed; /* input speed */speed = t c = ospeed; /* output speed */cc = t c = cc[NCCS]; /* control characters */
};
Figure 3-34. The termios structure.In MINIX tc� flag� t is ashort,speed� t is anint, cc� t is achar.
![Page 36: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/36.jpg)
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >TIME = 0 TIME > 0> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
MIN = 0 Return immediately with whateveris available, 0 to N bytes
Timer starts immediately. Return with firstbyte entered or with 0 bytes after timeout> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
MIN > 0 Return with at least MIN and up toN bytes. Possible indefinite block.
Interbyte timer starts after first byte. ReturnN bytes if received by timeout, or at least1 byte at timeout. Possible indefinite block> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >??????? ??????? ??????? ???????
Figure 3-35. MIN andTIME determinewhena call to readre-turns in noncanonicalmode. N is the number of bytes re-quested.
![Page 37: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/37.jpg)
� �������������������������������������������������������������������������������������������������������������������������������������������������������Escape sequence Meaning� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC [ n A Move up n lines� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC [ n B Move down n lines� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC [ n C Move right n spaces� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC [ n D Move left n spaces� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC [ m ; n H Move cursor to (m,n)� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC [ s J Clear screen from cursor (0 to end, 1 from start, 2 all)� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC [ s K Clear line from cursor (0 to end, 1 from start, 2 all)� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC [ n L Insert n lines at cursor� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC [ n M Delete n lines at cursor� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC [ n P Delete n chars at cursor� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC [ n @ Insert n chars at cursor� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC [ n m Enable rendition n (0=normal, 4=bold, 5=blinking, 7=reverse)� �������������������������������������������������������������������������������������������������������������������������������������������������������ESC M Scroll the screen backward if the cursor is on the top line� �����������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������
����������������������������
����������������������������
Figure 3-36. The ANSI escapesequencesacceptedby the ter-minal driver on output. ESCdenotestheASCII escapecharac-ter (0x1B),andn, m, ands areoptionalnumericparameters.
![Page 38: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/38.jpg)
User
FS
TTY
1 8@
6A
6A …
…2B
4
5C3
D7E
TTY Interrupt
Clock F
Interrupt
Figure 3-37. Readrequestfrom terminal when no charactersare pending. FS is the file system. TTY is the terminal task.Theinterrupthandlerfor theterminalqueuescharactersastheyare entered,but it is the clock interrupt handlerthat awakensTTY.
![Page 39: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/39.jpg)
Other functions
Receive message from clock
Receive message from user
via FS
tty_task
do_read handle_events
in_transfer
handle_events kb_read
Other functions
in_transfer
kb_read in_transfer
Figure 3-38. Input handling in the terminal driver. The leftbranchof the tree is takento processa requestto readcharac-ters.Theright branchis takenwhena character-has-been-typedmessageis sentto thedriver.
![Page 40: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/40.jpg)
tty_task
do_write
handle_events
cons_write
out_char
flush
pause_escape
Special characters
End of lineEscape
sequences“Easy”
characters
scroll_screen
Figure 3-39. Major proceduresusedon terminal output. Thedashedline indicatescharacterscopieddirectly to ramqueue bycons� write.
![Page 41: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/41.jpg)
��������������������������������������������������������������������������������������������������������������������Field Meaning��������������������������������������������������������������������������������������������������������������������
c " start Start of video memory for this console��������������������������������������������������������������������������������������������������������������������c " limit Limit of video memory for this console��������������������������������������������������������������������������������������������������������������������c " column Current column (0-79) with 0 at left��������������������������������������������������������������������������������������������������������������������c " row Current row (0-24) with 0 at top��������������������������������������������������������������������������������������������������������������������c " cur Offset into video RAM for cursor��������������������������������������������������������������������������������������������������������������������c " org Location in RAM pointed to by 6845 base register����������������������������������������������������������������������������������������������������������������������������������
��������������
��������������
Figure 3-40. Fields of the consolestructurethat relate to thecurrentscreenposition.
![Page 42: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/42.jpg)
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >Scan code Character Regular SHIFT ALT1 ALT2 ALT+SHIFT CTRL> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
00 none 0 0 0 0 0 0> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >01 ESC C(’[’) C(’[’) CA(’[’) CA(’[’) CA(’[’) C(’[’)> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >02 ’1’ ’1’ ’!’ A(’1’) A(’1’) A(’!’) C(’A’)> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >13 ’=’ ’=’ ’+’ A(’=’) A(’=’) A(’+’) C(’@’)> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >16 ’q’ L(’q’) ’Q’ A(’q’) A(’q’) A(’Q’) C(’Q’)> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >28 CR/LF C(’M’) C(’M’) CA(’M’) CA(’M’) CA(’M’) C(’J’)> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >29 CTRL CTRL CTRL CTRL CTRL CTRL CTRL> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >59 F1 F1 SF1 AF1 AF1 ASF1 CF1> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
127 ??? 0 0 0 0 0 0> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
??????????????????????????
Figure 3-41. A few entriesfrom a keymapsourcefile.
![Page 43: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/43.jpg)
� �����������������������������������������������������������������������������������������Field Default values� �����������������������������������������������������������������������������������������
c" iflag BRKINT ICRNL IXON IXANY� �����������������������������������������������������������������������������������������c" oflag OPOST ONLCR� �����������������������������������������������������������������������������������������c" cflag CREAD CS8 HUPCL� �����������������������������������������������������������������������������������������c" lflag ISIG IEXTEN ICANON ECHO ECHOE� ��������������������������������������������������������������������������������������������������� ���������� ����������
Figure 3-42. Default termiosflag values.
![Page 44: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/44.jpg)
� �����������������������������������������������������������������������������������������������������������������������������������POSIX function POSIX operation IOCTL type IOCTL parameter� �����������������������������������������������������������������������������������������������������������������������������������tcdrain (none) TCDRAIN (none)� �����������������������������������������������������������������������������������������������������������������������������������tcflow TCOOFF TCFLOW int=TCOOFF� �����������������������������������������������������������������������������������������������������������������������������������tcflow TCOON TCFLOW int=TCOON� �����������������������������������������������������������������������������������������������������������������������������������tcflow TCIOFF TCFLOW int=TCIOFF� �����������������������������������������������������������������������������������������������������������������������������������tcflow TCION TCFLOW int=TCION� �����������������������������������������������������������������������������������������������������������������������������������tcflush TCIFLUSH TCFLSH int=TCIFLUSH� �����������������������������������������������������������������������������������������������������������������������������������tcflush TCOFLUSH TCFLSH int=TCOFLUSH� �����������������������������������������������������������������������������������������������������������������������������������tcflush TCIOFLUSH TCFLSH int=TCIOFLUSH� �����������������������������������������������������������������������������������������������������������������������������������tcgetattr (none) TCGETS termios� �����������������������������������������������������������������������������������������������������������������������������������tcsetattr TCSANOW TCSETS termios� �����������������������������������������������������������������������������������������������������������������������������������tcsetattr TCSADRAIN TCSETSW termios� �����������������������������������������������������������������������������������������������������������������������������������tcsetattr TCSAFLUSH TCSETSF termios� �����������������������������������������������������������������������������������������������������������������������������������tcsendbreak (none) TCSBRK int=duration� ���������������������������������������������������������������������������������������������������������������������������������������������
������������������
����������������������������
����������������������������
����������������������������
����������������������������
Figure 3-43. POSIXcallsandIOCTL operations.
![Page 45: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/45.jpg)
� ���������������������������������������������������������������������������������������������������������������������������������0 V D N c c c c 7 6 5 4 3 2 1 0� ����������������������������������������������������������������������������������������������������������������������������������� �� �� �� �� �� �� �� �� �� �� �� �� �� �� �� ��
V: IN " ESC, escaped by LNEXT (CTRL-V)
D: IN " EOF, end of file (CTRL-D)
N: IN " EOT, line break (NL and others)
cccc: count of characters echoed
7: Bit 7, may be zeroed if ISTRIP is set
6-0: Bits 0-6, ASCII code
Figure 3-44. The fields in a charactercodeasit is placedintotheinput queue.
![Page 46: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/46.jpg)
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >42 35 170 18 38 38 24 57 54 17 182 24 19 38 32 28> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
Figure 3-45. Scancodesin the input buffer, with correspond-ing key pressesbelow, for a line of text enteredat the key-board. L+, L-, R+, andR- represent,respectively,pressingandreleasingthe left and right Shift keys. The code for a keyreleaseis 128morethanthecodefor a pressof thesamekey.
![Page 47: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/47.jpg)
� �����������������������������������������������������������������������������������������������������������Key Scan code ‘‘ASCII’’ Escape sequence� �����������������������������������������������������������������������������������������������������������
Home 71 0x101 ESC [ H� �����������������������������������������������������������������������������������������������������������Up Arrow 72 0x103 ESC [ A� �����������������������������������������������������������������������������������������������������������Pg Up 73 0x107 ESC [ V� �����������������������������������������������������������������������������������������������������������− 74 0x10A ESC [ S� �����������������������������������������������������������������������������������������������������������Left Arrow 75 0x105 ESC [ D� �����������������������������������������������������������������������������������������������������������5 76 0x109 ESC [ G� �����������������������������������������������������������������������������������������������������������Right Arrow 77 0x106 ESC [ C� �����������������������������������������������������������������������������������������������������������+ 78 0x10B ESC [ T� �����������������������������������������������������������������������������������������������������������End 79 0x102 ESC [ Y� �����������������������������������������������������������������������������������������������������������Down Arrow 80 0x104 ESC [ B� �����������������������������������������������������������������������������������������������������������Pg Dn 81 0x108 ESC [ U� �����������������������������������������������������������������������������������������������������������Ins 82 0x10C ESC [ @� �������������������������������������������������������������������������������������������������������������������������������������
��������������������������
��������������������������
��������������������������
��������������������������
Figure 3-46. Escapecodesgeneratedby the numerickeypad.When scancodesfor ordinary keys are translatedinto ASCIIcodesthe special keys are assigned‘‘pseudo ASCII’’ codeswith valuesgreaterthan0xFF.
![Page 48: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/48.jpg)
� ���������������������������������������������������������������������������������������������������������������Key Purpose� ���������������������������������������������������������������������������������������������������������������F1 Display process table� ���������������������������������������������������������������������������������������������������������������F2 Display details of process memory use� ���������������������������������������������������������������������������������������������������������������F3 Toggle between hardware and software scrolling� ���������������������������������������������������������������������������������������������������������������F5 Show Ethernet statistics (if network support compiled)� ���������������������������������������������������������������������������������������������������������������
CF7 Send SIGQUIT, same effect as CTRL-\� ���������������������������������������������������������������������������������������������������������������CF8 Send SIGINT, same effect as DEL� ���������������������������������������������������������������������������������������������������������������CF9 Send SIGKILL, same effect as CTRL-U� �������������������������������������������������������������������������������������������������������������������������������
����������������
����������������
Figure 3-47. Thefunctionkeysdetectedby func� key().
![Page 49: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/49.jpg)
ESCNot “[”
call do_escape
“[” numeric or “;”
collect numeric
parameters
Not numeric or “;”
call do_escape
Not ESC
c_esc_state = 1
c_esc_state = 0 c_esc_state = 2
Figure 3-48. Finite state machine for processingescapese-quences.
![Page 50: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/50.jpg)
� �������������������������������������������������������������������������������������Registers Function� �������������������������������������������������������������������������������������10 – 11 Cursor size� �������������������������������������������������������������������������������������12 – 13 Start address for drawing screen� �������������������������������������������������������������������������������������14 – 15 Cursor position� ��������������������������������������������������������������������������������������������� �������� ��������Figure 3-49. Someof the6845’sregisters.
![Page 51: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/51.jpg)
� ���������������������������������������������������������������������������������������������������������������������������������������������������Message type From Meaning� ���������������������������������������������������������������������������������������������������������������������������������������������������
SYS " FORK MM A process has forked� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " NEWMAP MM Install memory map for a new process� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " GETMAP MM MM wants memory map of a process� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " EXEC MM Set stack pointer after EXEC call� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " XIT MM A process has exited� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " TIMES FS FS wants a process’ execution times� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " ABORT Both Panic: MINIX is unable to continue� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " SENDSIG MM Send a signal to a process� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " SIGRETURN MM Cleanup after completion of a signal.� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " KILL FS Send signal to a process after KILL call� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " ENDSIG MM Cleanup after a signal from the kernel� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " COPY Both Copy data between processes� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " VCOPY Both Copy multiple blocks of data between processes� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " GBOOT FS Get boot parameters� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " MEM MM MM wants next free chunk of physical memory� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " UMAP FS Convert virtual address to physical address� ���������������������������������������������������������������������������������������������������������������������������������������������������SYS " TRACE MM Carry out an operation of the PTRACE call� ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������������������
������������������������������
������������������������������
Figure 3-50. Themessagetypesacceptedby thesystemtask.
![Page 52: INPUT/OUTPUTxcellenttutorial.weebly.com/uploads/5/4/1/2/5412925/osdi2-3.pdf · 3 input/output 3.1 principles of i/o hardware 3.2 principles of i/o software 3.3 deadlocks 3.4 overview](https://reader033.vdocuments.us/reader033/viewer/2022043014/5fb29fcb7cb36007de2243d9/html5/thumbnails/52.jpg)
User
Disk task System task
Interrupt
(a)
FS
1
542 6
7
3
User
Disk task System task
Interrupt
(b)
FS
1
2 3
4
Figure 3-51. (a) Worstcasefor readinga block requiressevenmessages.(b) Bestcasefor readinga block requiresfour mes-sages.