[OS] Operating System Structure 1

Updated:

Operating System Structure Part 1

Operating System Services

Operating systems provide an environment for execution of programs and services to programs and users.
One set of operating system services provides functions that are helpful to the user

  • User Interface : CLI, GUI, etc…
  • Program execution
    • load a program into memory and run that program
    • end execution, either normally or abnormally.
  • I/O operations
    • A running program may require I/O, which may involve a file or an I/O device
  • File-system manipulation
    • Programs need to create, delete, read and write files and directories
    • search, list file information, and permission management
  • Communications
    • Processes may exchange information on the same computer or between computers over a network
    • Communications may be via shared memory or through message passing (packets moved by the OS)
  • Error detection
    • OS needs to be constantly aware of possible errors
    • May occur in the CPU and memory hardware, in I/O devices, in user program
    • Take the appropriate action to ensure correct and consistent computing
    • Debugging facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system
  • Resource allocation
    • When multiple users or multiple jobs running concurrently, resources must be allocated to each of them
  • Accounting
    • To keep track of which users use how much and what kinds of computer resources
  • Protection and Security
    • Protection involves ensuring that all access to system resources is controlled
    • Security of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts

os

System Calls : Programming interface to the services provided by the OS

system_Call

  • CPU operates in “user mode” or “kernel mode”
    • allows OS to protect itself and other system components (separate critical things from general things)
    • Mode bit (provided by hardware) allows to distinguish on which mode the system is running
    • Some privileged instructions (ex. HLT) are only executable in the kernel mode
  • Privileged Instructions : a set of instructions that should be executed carefully
    • Direct I/O access
    • Accessing / manipulating system registers (control registers, interrupt service routine table)
    • Memory state management (page table updates, page table pointers, TLB loads …)
    • HLT instruction
    • Only executable in the kernel mode
    • May generate an execption if an application tries to run a privileged instruction in user mode
  • Interrupt vs. Exception
    • Exceptioon
      • Generated by software executing instructions (software error, unauthorized access of data, request for operating system service, …)
      • Synchronous (happens when CPU executes an instruction)
      • Trap (expected, intended) or fault(unexpected)
    • Interrupt
      • Generated by hardware devices
      • Occurs asynchronously (at any time)

sys_Call

  • Mostly accessed by programs via a high-level Application Programming Interface (API) rather than direct system call use
  • 3 most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems, and Java API for the JVM(Java Virtual Machine)

System Call Implementation

  • Typically, a number is assoicated with each system call
  • The system call interface maintains a table indexed according to these numbers
  • The system call interface invokes the intended system call in OS kernel and returns status of the system and any return values
  • The caller needs to know nothing about how the system call is implemented

Example of System Calls

EX

Examples of Windows and Unix System Calls

ex2

Standard C library Example

  • C program invoking printf() library call, which calls write() system call c_syscall

System Call Parameter Passing

Often, more information is required than simply the identity of the desired system call.
Exact type and amount of information vary according to OS and call type.
Three general methods used to pass parameters to the OS

  1. Pass the parameters in registers
    • Problem: limited number of registers
  2. Parameters stored in a block, or table in memory and address of block passesd as a parameter in a register (Pointer passsing)
  3. Parameters are placed, or pushed onto the stack by the program and popped off the stack by the OS.

Leave a comment