Updated:

3/1 W1 L1

We need to understand the ecosystem of where our application is running. Running too slow? Know where to optimize it.

What hardware and software components are involved between recording a video and getting it to viewers?

  • CPU memory to process and render the video
  • Network protocol to get the recording to the colud
  • Hosting the recording on the cloud
  • Web application where a user connects
  • User downloads and watches it

Topic

  • The role of the operating system
  • The memory hierarchy (caches, virtual memory)
    • Where is it stored?
  • Interrupt handling, processes and scheduling
    • Multiple processes running at the same time?
  • Introduction to multiprocessors and synchronization
    • Conflict resolution
  • Computer system security and cryptographic protocols
  • Introduction to network protocols (OSI model)
  • Development of client-server applications

Components of a modern computer

  • 1+ processors
  • Main memory
  • Disks
  • Printers
  • Keyboard
  • Mouse
  • Display
  • Network interfaces
  • I/O devices

These are hardwares. OS seamlessly takes care of everything!

Operating systems

OS is a layer in between the hardware and the software. (The manager that makes sure that the recipe is done in the kitchen)

Examples: Windows, macOS, Unix, Linux, Android… GUI or a command line shell is not an operating system.

  • OS Provides an **1. abstraction**
    • Abstraction between the hardware resources and the software that is running on it. → The developer can ignore the underlying processes.
    • i.e. The main cook in the kitchen that makes sure that the recipe is done

    1

  • OS as a **2. resource manager**
    • Managing: ensuring that the software get their CPU time, all being run
    • Top down view
      • Provide abstractions to application programs
    • Bottom up view
      • Manage pieces of complex system
    • Alternative view
      • Provide orderly, controlled allocation of resources
      • Isolation of the memory given to different programs?
  • OS as an **3. extended machine**
    • OS turns ugly hardware into beautiful abstractions.

    2

History of OS

  • Driven by computer architecture
    • The first generation (1945–55) vacuum tubes
    • The second generation (1955–65) transistors and batch systems
    • The third generation (1965–1980) integrated circuits and multiprogramming
    • The fourth generation (1980–present) personal computers
    • The fifth generation (1990–present) mobile computers

OS concepts

  • Processes (running program)
  • Address spaces (memory)
  • Files and file system
  • Input and Output
  • Protection (manage security)

Typical memory hierarchy

3

3/3 W1 L2: Introduction to Processes and Process Management

Processor/CPU

  • Central processing unit (CPU)
  • Fetches instructions from registers (memory); executes them (marks the job done)
  • Registers keep some process state information
  • Two modes of execution:
    • Kernel (execute any CPU instruction and reference any memory address) i.e. initiate I/O
    • User (only a subset) i.e. add, sub
  • CPU: The cooks that are doing the job, Kernel: higher level chef that deals with important ingredients

Processes: program in execution

  • Key concept in all operating systems
  • At any given time, the number of processes running a given program can be 0, 1, 2, 3, ….
  • Assocciated with an address space & set of resources
  • A container that holds all info needed to run the program
  • A process is dynamic (↔ a program is static)
    • The state of a process consists of:
      • The code / text of the program
      • The values of all the variables in memory and registers
      • Address of the current instruction
      • Current directory, etc.
    • Act of cooking (=process) is dynamic <-> A recipe is a static entity (=program)

Typically, number of processes run by a machine > number of CPUs

Multiple processes

  • Each process has its own address space
    • The state of the process has to be remembered, which requires "complete isolation" between processes
  • Process memory has three segments:
    • text (program code, “read only”)
    • data (constant data strings, global vars)
    • stack (local vars like functions and state of the variable)
  • Conceptually, each process has its own virtual CPU.
  • In reality, multiple processes share a CPU, each taking a small period of time to run. (multiprogramming)

    4

OS as a process

  • Another way of defining the OS: process
  • OS ensures that different proesses do not get in each other’s way while they are active at the “same” time
  • Provides services such as “read N bytes from this file”, which is used by application programs, utilities, and non-privileged parts of the OS.

User vs. Kernel mode

  • The program status word (PSW) register gives the CPU its current mode.
    • Code running in User mode

      cannot issue privileged instructions, and can only access the parts of memory that is allowed by kernel mode code.

    • Code running in kernel mode

      can issue all instructions, and can access all memory.

    • Privileged instructions and memory locations: those which access anything that might interfere with another system (i.e. accessing I/O device)
  • User / kernel distinction builds the security mechanisms for OS.

System call

  • Transition between user and kernel mode is made via system calls
    • Allow user programs to ask the OS to execute privileged instructions / memory locations on their behalf.
    • Preserves system integrity and security since OS checks the requst before executing them.
    • Several privileged things are carried out as a single logical operation to make system calls more convenient to use.
  • To the application programmer: system call = call to a privileged function

    5

  • Mode bit (register) helps you distinguish which mode the system is running on.

    image

  • Example of a system call: Standard C library handling of write(). The library provides the system-call interface.

Typical system calls

  • Process control (load/execute; create and terminate a process; get/set process attributes)
  • File management (read/create/delete/open/close a file; get/set file attributes)
  • Device management (request/release a device; read/write from a device)
  • Information maintenance (get/set time or date)
  • Communication (create/delete communication connections)

Leave a comment