Introductionمقدمة في نظم التشغيل
مقدمة الفصل
ماذا ستتعلم في هذا الفصل
- What an operating system is and what it does (goals, resource allocator, control program, kernel).
- Computer-system organization: startup, device controllers, interrupts, I/O structure, DMA and storage.
- Computer-system architecture: single-processor and multiprocessor systems.
- Operating-system structure and operations: multiprogramming, timesharing, dual-mode operation and the timer.
أقسام الفصل
- 1What is an operating system?ما نظام التشغيل؟
- 2The four components of a computer systemالمكونات الأربعة لنظام الحاسب
- 3Computer startupإقلاع الحاسب
- 4Computer-system operation and interruptsتشغيل الحاسب والمقاطعات
- 5I/O structure, the device-status table and DMAبنية الإدخال والإخراج وجدول حالة الأجهزة والوصول المباشر للذاكرة
- 6Storage structure, hierarchy and cachingبنية التخزين والهرم والتخزين المؤقت
- 7Computer-system architecture: multiprocessorsمعمارية الحاسب: المعالجات المتعددة
- 8Multiprogramming and timesharingالبرمجة المتعددة والمشاركة الزمنية
- 9Operating-system operations: dual mode and the timerعمليات نظام التشغيل: نمطا التشغيل والمؤقت
تلميح: استخدم أسهم لوحة المفاتيح للتنقل بين الشرائح.
What is an operating system?تعريف نظام التشغيل
A program that acts as an intermediary between a user of a computer and the computer hardware.
Operating system goals
- Execute user programs and make solving user problems easier.
- Make the computer system convenient to use.
- Use the computer hardware in an efficient manner.
Manages all resources; decides between conflicting requests for efficient and fair resource use.
Controls execution of programs to prevent errors and improper use of the computer.
"The one program running at all times on the computer." Everything else is a system program (ships with the OS) or an application program.
Four components of a computer systemمكونات نظام الحاسب
| Componentالمكوّن | Role (slide 5)الدور | Examplesأمثلة |
|---|---|---|
| Hardware | Provides basic computing resources | CPU, memory, I/O devices |
| Operating system | Controls and coordinates use of hardware among various applications and users | لا تذكر الشرائح شيئًا هنا. |
| Application programs | Define the ways in which the system resources are used to solve the computing problems of the users | Word processors, compilers, web browsers, database systems, video games |
| Users | لا تذكر الشرائح شيئًا هنا. | People, machines, other computers |
Computer startupالإقلاع
From power-up to the kernel (slide 9)
- 1
The bootstrap program is loaded at power-up or reboot.
- 2
BIOS (stored in ROM or EPROM, known as firmware) runs and initializes various parts of PC hardware.
- 3
BIOS checks for a specific sector in the defined first boot device (typically the hard disk).
- 4
The bootstrap program in the boot sector is loaded in memory and starts loading the operating system kernel.
Device controllers and interruptsالمتحكمات والمقاطعات
Computer-system operation and interrupts
- CPUs and device controllers connect through a common bus providing access to shared memory; they execute concurrently, competing for memory cycles.
- Each device controller is in charge of a particular device type and has a local buffer; I/O is from the device to the controller's local buffer, and the CPU moves data between main memory and the local buffers.
- The device controller informs the CPU that it has finished its operation by causing an interrupt.
Contains the addresses of all the service routines; an interrupt transfers control to the interrupt service routine generally through it.
A software-generated interrupt caused either by an error or a user request.
- The interrupt architecture must save the address of the interrupted instruction.
- Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt.
- An operating system is interrupt driven.
Interrupt handlingمعالجة المقاطعة
Computer-system operation and interrupts
Interrupt handling (slide 13)
- 1
The OS preserves the state of the CPU by storing registers and the program counter.
- 2
It determines which type of interrupt has occurred: polling or a vectored interrupt system.
- 3
Separate segments of code determine what action should be taken for each type of interrupt.
Synchronous vs asynchronous I/Oالإدخال والإخراج
I/O structure, the device-status table and DMA
Synchronousمتزامن
- After I/O starts, control returns to the user program only upon I/O completion.
- A wait instruction idles the CPU until the next interrupt (or a wait loop).
- At most one I/O request is outstanding at a time — no simultaneous I/O processing.
Asynchronousغير متزامن
- After I/O starts, control returns to the user program without waiting for I/O completion.
- A system call lets the user wait for I/O completion if desired.
- The device-status table keeps track of many I/O requests at the same time.
Contains an entry for each I/O device indicating its type, address, and state. If the device is busy, the type of request and other parameters are stored in its entry, and a queue contains the list of requests waiting for that device.
Direct memory access (DMA)الوصول المباشر للذاكرة
I/O structure, the device-status table and DMA
Used for high-speed I/O devices able to transmit information at close to memory speeds. The device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention.
- Only one interrupt is generated per block, rather than one interrupt per byte.
Storage structure and hierarchyهرم التخزين
Storage structure, hierarchy and caching
The only large storage media that the CPU can access directly.
An extension of main memory that provides large nonvolatile storage capacity.
Rigid metal or glass platters covered with magnetic recording material; the surface is divided into tracks, subdivided into sectors; the disk controller determines the logical interaction between the device and the computer.
Storage-device hierarchy, top to bottom (slide 20)
- 1
Registers
- 2
Cache
- 3
Main memory
- 4
Electronic disk
- 5
Magnetic disk
- 6
Optical disk
- 7
Magnetic tapes
- Storage systems are organized in a hierarchy by speed, cost and volatility.
Cachingالتخزين المؤقت
Copying information into a faster storage system; main memory can be viewed as a last cache for secondary storage.
How a cache is used (slide 21)
- 1
Information in use is copied from slower to faster storage temporarily.
- 2
The faster storage (cache) is checked first to determine if the information is there.
- 3
If it is, the information is used directly from the cache (fast).
- 4
If not, the data is copied to the cache and used there.
- The cache is smaller than the storage being cached → cache management is an important design problem: cache size and replacement policy.
- Multitasking environments must use the most recent value, no matter where it is in the hierarchy — cache consistency (slide 22).
Multiprocessor systemsالمعالجات المتعددة
Computer-system architecture: multiprocessors
Growing in use and importance; also known as parallel systems or tightly-coupled systems.
- 1Increased throughput
- 2Economy of scale
- 3Increased reliabilityGraceful degradation or fault tolerance.
Two types
- Asymmetric multiprocessing
- Symmetric multiprocessing (architecture shown on slide 24)
Multiprogramming and timesharingالبرمجة المتعددة
Multiprogrammingالبرمجة المتعددة
- Needed for efficiency: a single user cannot keep the CPU and I/O devices busy at all times.
- Organizes jobs so the CPU always has one to execute; a subset of jobs is kept in memory.
- One job is selected via job scheduling; when it has to wait (e.g., for I/O), the OS switches to another job.
Timesharing (multitasking)المشاركة الزمنية
- A logical extension of multiprogramming: the CPU switches jobs so frequently that users can interact with each job while it is running.
- Response time should be < 1 second.
- Program in memory → process; several ready → CPU scheduling; not fitting → swapping; virtual memory runs processes not completely in memory.
Dual-mode operationنمطا التشغيل
Operating-system operations: dual mode and the timer
- A software error or request creates an exception or trap — e.g., division by zero, request for operating system service.
- Dual-mode operation allows the OS to protect itself and other system components: user mode and kernel mode.
- A mode bit provided by hardware distinguishes when the system is running user code or kernel code.
- Privileged instructions are only executable in kernel mode.
A system call (slide 29)
- 1
The user's code issues a system call.
- 2
The mode is changed to kernel mode.
- 3
The OS first checks that everything (e.g., parameter values) is in order and legal.
- 4
The OS executes the system call, which may contain multiple privileged instructions.
- 5
The mode is set again to user mode.
The timerالمؤقت
Prevents an infinite loop / a process hogging resources.
- 1
Set an interrupt after a specific period.
- 2
The operating system decrements a counter.
- 3
When the counter is zero, generate an interrupt.
- Set up before scheduling a process to regain control or terminate a program that exceeds its allotted time.
الخلاصة
أنهيت الدرس
الخطوة التالية: ثبّت المعلومات بالبطاقات، ثم اختبر نفسك بالأسئلة.
ما راجعته في هذا الدرس
- What is an operating system?ما نظام التشغيل؟
- The four components of a computer systemالمكونات الأربعة لنظام الحاسب
- Computer startupإقلاع الحاسب
- Computer-system operation and interruptsتشغيل الحاسب والمقاطعات
- I/O structure, the device-status table and DMAبنية الإدخال والإخراج وجدول حالة الأجهزة والوصول المباشر للذاكرة
- Storage structure, hierarchy and cachingبنية التخزين والهرم والتخزين المؤقت
- Computer-system architecture: multiprocessorsمعمارية الحاسب: المعالجات المتعددة
- Multiprogramming and timesharingالبرمجة المتعددة والمشاركة الزمنية
- Operating-system operations: dual mode and the timerعمليات نظام التشغيل: نمطا التشغيل والمؤقت