I/O Management and Disk Schedulingإدارة الإدخال والإخراج وجدولة القرص
مقدمة الفصل
ماذا ستتعلم في هذا الفصل
- I/O devices: the three categories and how devices differ.
- Organization of the I/O function: programmed I/O, interrupt-driven I/O, DMA and its configurations.
- Operating system design issues (efficiency, generality, hierarchical design) and I/O buffering.
- Disk performance parameters and disk scheduling policies: FIFO, priority, LIFO, SSTF, SCAN, C-SCAN, N-step-SCAN, FSCAN.
أقسام الفصل
- 1Categories of I/O deviceفئات أجهزة الإدخال والإخراج
- 2Differences in I/O devicesاختلافات أجهزة الإدخال والإخراج
- 3Techniques for performing I/O and DMA configurationsتقنيات الإدخال والإخراج وتشكيلات DMA
- 4OS design issues and I/O bufferingقضايا التصميم والتخزين المؤقت للإدخال والإخراج
- 5Disk performance parametersمعاملات أداء القرص
- 6Disk scheduling: FIFO, priority, LIFOجدولة القرص: FIFO والأولوية وLIFO
- 7Disk scheduling: SSTF, SCAN, C-SCAN, N-step-SCAN, FSCANجدولة القرص: SSTF وSCAN وC-SCAN وN-step-SCAN وFSCAN
تلميح: استخدم أسهم لوحة المفاتيح للتنقل بين الشرائح.
Categories of I/O deviceفئات الأجهزة
- A difficult area of OS design: a consistent solution is hard because of the wide variety of devices and applications.
| Categoryالفئة | Used to communicate withللتواصل مع | Examples (slides 4–6)أمثلة |
|---|---|---|
| Human readable | The user |
|
| Machine readable | Electronic equipment |
|
| Communication | Remote devices |
|
Differences in I/O devicesاختلافات الأجهزة
ستة أوجه اختلاف.
- Data rate
There may be a massive difference between the data transfer rates of devices.
- Application
A disk for files needs file management software; a disk for virtual memory pages needs special hardware and software; a system administrator's terminal may have a higher priority.
- Complexity of control
A printer needs a relatively simple control interface; a disk is much more complex (filtered to some extent by the I/O module).
- Unit of transfer
A stream of bytes or characters (e.g., terminal I/O) or larger blocks (e.g., disk I/O).
- Data representation
Different encoding schemes, including differences in character code and parity conventions.
- Error conditions
How errors are reported, their consequences and the available range of responses differ widely.
Techniques for performing I/Oتقنيات الإدخال والإخراج
| No interruptsدون مقاطعات | Use of interruptsباستخدام المقاطعات | |
|---|---|---|
| I/O-to-memory transfer through processor | Programmed I/O | Interrupt-driven I/O |
| Direct I/O-to-memory transfer | لا تذكر الشرائح شيئًا هنا. | Direct memory access (DMA) |
DMA configurationsتشكيلات DMA
All modules share the same system bus.
A direct path between DMA and I/O modules — this substantially cuts the required bus cycles.
Reduces the number of I/O interfaces in the DMA module.
Design issues: efficiency and generalityقضايا التصميم
OS design issues and I/O buffering
Efficiency (slide 20)
- Most I/O devices are extremely slow compared to main memory; I/O cannot keep up with processor speed.
- Multiprogramming lets some processes wait on I/O while another executes.
- Swapping brings in ready processes — but swapping is an I/O operation itself.
Generality (slide 21)
- Handle all I/O devices in a uniform manner; hide most details in lower-level routines.
- Hard to completely generalize, but a hierarchical modular design can be used.
An OS organized into layers: each layer relies on the next lower layer for more primitive functions and provides services to the next higher layer; changes in one layer should not require changes in other layers.
I/O bufferingالتخزين المؤقت
- Processes must wait for I/O to complete before proceeding.
- To avoid deadlock, certain pages must remain in main memory during I/O.
- It may be more efficient to perform input transfers in advance of requests and output transfers some time after the request is made.
Disk performance parametersأداء القرص
- When operating, the disk is rotating at constant speed.
- Track selection: moving the head (movable-head system) or electronically selecting one head (fixed-head system).
المسألة
Access time (slide 28).
المعطيات
- Seek time
- time to position the head at the desired track
- Rotational delay (latency)
- time for the beginning of the sector to reach the head
الصيغة
Access time = seek time + rotational delay
النتيجة
Transfer time — the time taken to transfer the data — comes after the access.
FIFO, priority and LIFOFIFO والأولوية وLIFO
Disk scheduling: FIFO, priority, LIFO
Comparison setup (slide 29)
- Head initially at track 100; disk with 200 tracks.
- Requests in the order received: 55, 58, 39, 18, 90, 160, 150, 38, 184.
Process requests sequentially; fair to all processes; approaches random scheduling in performance if there are many processes.
Goal is not to optimize disk use but to meet other objectives: short batch jobs may have higher priority; good interactive response; longer jobs may wait an excessively long time; a poor policy for database systems.
Good for transaction processing systems; the device goes to the most recent user → little arm movement; possibility of starvation since a job may never regain the head of the line.
SSTF, SCAN and C-SCANSSTF وSCAN
Disk scheduling: SSTF, SCAN, C-SCAN, N-step-SCAN, FSCAN
Select the request that requires the least movement of the disk arm from its current position — always choose the minimum seek time.
The arm moves in one direction only, satisfying all outstanding requests, then the direction is reversed.
Restricts scanning to one direction only; after the last track in that direction, the arm is returned to the opposite end and the scan begins again.
N-step-SCAN and FSCANN-step وFSCAN
Disk scheduling: SSTF, SCAN, C-SCAN, N-step-SCAN, FSCAN
N-step-SCAN
- Segments the disk request queue into subqueues of length N
- Subqueues are processed one at a time, using SCAN
- New requests are added to another queue while a queue is processed
FSCAN
- Two subqueues
- When a scan begins, all requests are in one queue, the other empty
- All new requests go to the other queue; their service is deferred until all old requests have been processed
Performance comparedمقارنة الأداء
Disk scheduling: SSTF, SCAN, C-SCAN, N-step-SCAN, FSCAN
| Policyالسياسة | Order of tracks accessed from track 100 (slide 38)ترتيب المسارات من 100 | Average seek lengthمتوسط طول البحث |
|---|---|---|
| FIFO | 55, 58, 39, 18, 90, 160, 150, 38, 184 | 55.3 |
| SSTF | 90, 58, 55, 39, 38, 18, 150, 160, 184 | 27.5 |
| SCAN (increasing) | 150, 160, 184, 90, 58, 55, 39, 38, 18 | 27.8 |
| C-SCAN (increasing) | 150, 160, 184, 18, 38, 39, 55, 58, 90 | 35.8 |
المسألة
SSTF from track 100 (slide 38): how is each step chosen?
خطوات الحل
- From 100 the nearest request is 90 (10 tracks).
- Then 58 (32), 55 (3), 39 (16), 38 (1), 18 (20).
- Then 150 (132), 160 (10), 184 (24).
- Total = 248 tracks for 9 requests.
النتيجة
Average seek length = 248 / 9 ≈ 27.5.
الخلاصة
أنهيت الدرس
الخطوة التالية: ثبّت المعلومات بالبطاقات، ثم اختبر نفسك بالأسئلة.
ما راجعته في هذا الدرس
- Categories of I/O deviceفئات أجهزة الإدخال والإخراج
- Differences in I/O devicesاختلافات أجهزة الإدخال والإخراج
- Techniques for performing I/O and DMA configurationsتقنيات الإدخال والإخراج وتشكيلات DMA
- OS design issues and I/O bufferingقضايا التصميم والتخزين المؤقت للإدخال والإخراج
- Disk performance parametersمعاملات أداء القرص
- Disk scheduling: FIFO, priority, LIFOجدولة القرص: FIFO والأولوية وLIFO
- Disk scheduling: SSTF, SCAN, C-SCAN, N-step-SCAN, FSCANجدولة القرص: SSTF وSCAN وC-SCAN وN-step-SCAN وFSCAN