-
User Program and System CallCS/OS 2024. 3. 6. 17:12
Terminologies : Kernel and Utility
- Kernel : Operating System의 핵심적인 기능을 수행하는 코드 (Software)
- Memory resident part of OS
- Majority written in C / Rest in assembler language (HW dependent, for speed)
- Consists of a set of functions
- Provide fundamental mechanisms (process management, synchronization, CPU scheduling, memory management, device management, interrupt handling)
- Provide services via a system call
- Utility (Command) : Disk resident programs (loaded on demand)
- Shell : A special utility for command control
Resource Protection
Dual-Mode Operation
- Need HW help to "prevent" illegal action.
- Provide hardware support to differentiate between at least two modes of operations
- Privileged instructions
- I/O instructions
- Instructions that manipulate memory management state
- Setting of special mode bits
- Halt instruction
- Mode transition by Interrupt / Trap / System Call
- Mode bit : Kernel (0) or User (1) in PSW
CPU Protection
- CPU protection mechanism : prevent monopolizing CPU, supporting a timer (HW)
- Programmable Interval Timer (PIT)
- Relative Time
- A hardware device to drive an interrupt at a periodic rate
- Almost kernel functions are time-driven
- Real Time Clock (RTC)
- Absolute Time
- A nonvolatile device to keep time when OS is not running
- Managing the current time of day
- System Timer (Privileged)
- Called PIT
- Used in time sharing systems
- Used to update the wall time
- Timer Interrupt Handler in Linux
- Update the jiffies (Relative Time; tics)
- Update the wall time, which is stored in xtime (Absolute Time)
- Update the process time
- Update resource usages for the currently running process
- Update time slice : check for quantum (time slice) expiration
Memory Protection
- Support the translation of logical (virtual) addresses to physical addresses
- Memory protection, cache control, bus arbitration
I/O Protection
- All I/O instructions are privileged instructions
- User cannot be allowed direct access to I/O
System Call
System Call
- Programming interface to OS services
- Allows applications to communicate with OS
- Purpose of system calls
- To protect system resources
- For reliability : buggy user program
- For security : malicious user program
- Important design principle
- Policy : What will be done?
- Mechanism : How to do it?
System Call Implementation
- User Programs
- Calls system call function in library
- Places arguments in registers and/or pushes tem onto user stack
- Places syscall number in a dedicated register
- Executes syscall machine instruction
- Kernel
- Executes syscall interrupt handler
- Executes dedicated kernel function in system call interface
- Place result in dedicated register
- Executes RETURN_FROM_INTERRUPT
- System Call Interface (Table)
- A number is associated with each system call
- A table indexed according to these numbers
- Invokes intended system call
System Call Parameter Passing
- Pass the parameters in registers
- Pass the parameters stored in a block in memory (address of block)
- Pass the parameters pushed onto the stack by the program
Type of System Calls
- Process
- Scheduling
- Interprocess communication (IPC)
- File system
- Socket (networking)
- Miscellaneous (기타 등등)
'CS > OS' 카테고리의 다른 글
Threads (0) 2024.04.17 Process Scheduling 2 (0) 2024.03.20 Process Scheduling 1 (0) 2024.03.13 Process Description and Control (0) 2024.03.06 Computer System Overview (0) 2024.02.26 - Kernel : Operating System의 핵심적인 기능을 수행하는 코드 (Software)