ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • User Program and System Call
    CS/OS 2024. 3. 6. 17:12

    Terminologies : Kernel and Utility

    1. 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
    2. Utility (Command) : Disk resident programs (loaded on demand)
    3. 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
      1. Update the jiffies (Relative Time; tics)
      2. Update the wall time, which is stored in xtime (Absolute Time)
      3. Update the process time
        • Update resource usages for the currently running process
        • Update time slice : check for quantum (time slice) expiration

     

    Memory Protection

    Memory Management Unit (MMU)

    • 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
      1. To protect system resources
      2. For reliability : buggy user program
      3. For security : malicious user program
    • Important design principle
      • Policy : What will be done?
      • Mechanism : How to do it?

     

    System Call Implementation

    • User Programs
      1. Calls system call function in library
      2. Places arguments in registers and/or pushes tem onto user stack
      3. Places syscall number in a dedicated register
      4. Executes syscall machine instruction
    • Kernel
      1. Executes syscall interrupt handler
      2. Executes dedicated kernel function in system call interface
      3. Place result in dedicated register
      4. 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
Designed by Tistory.