1. Definition:

  • Software that manages the computer hardware, as well as providing an environment for application programs to run
    • resource allocator of CPU time, memory,…
    • Control program for I/O devices
  • Includes Kernel and system programs
  • Interuption
  • To prevent user programs from interfering with the proper operation of the system, the system hardware has two modes: user mode and kernel mode.
  • Various instructions are privileged and can be executed only in kernel mode
    • Examples include the instruction to switch to kernel mode, I/O control, timer management,and interrupt management.
  • Storage space is managed by the operating system; this includes providing file systems for representing files and directories and managing space on mass-storage devices.
  • Operating systems provide mechanisms for protecting and securing the operating system and users. Protection measures control the access of processes or users to the resources made available by the computer system.
  • Data structures that are used in an operating system include lists, stacks, queues, trees, and maps.

2. Operating System structures:

  • Operating-System Services:
  • User Interface: GUI, CLI, Touch-screen interface
  • System calls: API for programs (win32 API, POSIX API, Java API)
  • System services
  • Linker and Loader
  • Operating-System design and implementation:
    • User goal vs system goal
    • Policy from mechanism
    • Implementation

3. Process and Thread

Deadlock

Memory and Memory-management Unit

Mass storage structure:

Storage
Disk scheduling:
  • Logical Block Addressing, LBA:
    • Smallest unit of data transferable, each block maps to a physical sector of HDD or semi-conductor page
  • When a process needs I/O, it issues a System Call to the OS, which need several pieces of infor:
    • disk/memory address
    • number of logical blocks to be transfered
  • Scheduling algorithms for HDD:
    • Evaluated on:
      • Device bandwidth = the total number of bytes transferred/the total between the first request for service and the completion of the last transfer.
      • The total head movement from the first transfer request to the last transfer request. (#cylinders)
    • FCFS: move the the next on in the queue
      • can be zigzag
    • SSTF (shortest seek time first): move the the closest pending position first
      • can cause starvation
      • greedy approach
    • SCAN: The head moves toward one direction while servicing all the requests in that direction until it reaches the end of the disk (at 0 or max). After that, it starts moving in the other direction
      • elevator algorithm
    • C-SCAN: Similar to SCAN, but when the head reaches the other end (at max), however, it immediately returns to the beginning of the disk (at 0) without servicing any requests on the return trip
    • C-LOOK: Similar to SCAN, but but is its practical version, where the head moves towards one direction while servicing all the requests in that direction until it reaches the last request (without reaching the max). After that it starts moving towards the other direction
    • Linux utilizes “deadline scheduler” which maintains separate read and write queues, and gives read priority
  • SSD scheduling: Flash memory-based devices do not contain moving disk heads and therefore, doesnt make a difference in which is read first use FCFS
Storage device management & RAIDs:

Filesystem

  • File
  • File-control Block, FCB:dynamic data structure that is created in memory when a file is opened. It’s used to manage the file while it’s open
    • in memory
    • when click open, check inode first, then add fcb in system-wide open-file table
  • Filesystem
  • In-memory file system structures:
    • Mount Table store file system mounts, mount points, file system types
    • System-wide open-file table: contains a copy of the FCB of each file and other info
    • Per-process open-file table: contain pointers to appropriate entries in system-wide open-file table as well as other info
Directory implementation
Free space management
  • File systems maintains free-space list to track available blocks
  • Bit vector/map, where bit[i] = 1 if free, 0 otherwise
  • Used block number = nb of bits per word * nb of 0 + offset of first 1s
    • word is cluster of blocks, 1 if all blocks are free, 0 otherwise
  • other techniques:
    • Grouping:
      • modify linked list to store address of next n-1 blocks in the first block of the group, and a pointer to the first block of next group
    • Counting:
      • update free/used blocks
    • Space maps:
      • Consider meta-data I/O on large file systems
      • Full data structures like bit maps cannot fit in memory for too many I/Os
    • Linked list of free blocks
      • a free block links to another
      • Faster to write with linked File allocation on disk’s linking allocation
        • no need to search next free blocks
  • Performance considerations:
    • Keeping data and metadata close together
    • Buffer cache – separate section of main memory for frequently used blocks
    • Synchronous writes sometimes requested by apps or needed by OS
      • No buffering / caching – writes must hit disk before acknowledgement
      • Asynchronous writes more common, buffer-able, faster
    • Free-behind and read-ahead – techniques to optimize sequential access
    • Reads frequently slower than writes
  • Recovery:
    • Consistency checking – compares data in directory structure with data blocks on disk, and tries to fix inconsistencies
      • Can be slow and sometimes fails
    • Use system programs to back up data from disk to another storage device (magnetic tape, other magnetic disk, optical)
    • Recover lost file or disk by restoring data from backup

Cyber Security