CS 162 Midterm 1 Review

c review session

basics

pointers

memory layout

Screen Shot 2022-09-25 at 3.27.59 PM.png

data structures

useful functions

lec 1: what is an operating system

Screen Shot 2022-09-25 at 4.11.12 PM.png

lec 2: processes and kernels

requirements for virtualization

what is a process

Screen Shot 2022-09-25 at 4.14.51 PM.png

Screen Shot 2022-09-25 at 4.17.02 PM.png

operating system kernel

user vs kernel

hardware will support

safe control transfer

Screen Shot 2022-09-25 at 4.46.04 PM.png

lec 3: processes cont.

stack review

pointers

Screen Shot 2022-09-25 at 9.12.08 PM.png

Screen Shot 2022-09-25 at 9.16.29 PM.png

big idea

user → kernel mode

1. interrupt detection (hardware)

Screen Shot 2022-09-25 at 9.40.04 PM.png

  1. device sends electric signal over interrupt request line (IRQ) to interrupt controller
  2. APIC converts IRQ to a vector number and sends signal to processor
  3. processor detects interrupt by the IRQ code

Screen Shot 2022-09-25 at 9.41.06 PM.png

2. save recovery state (hardware)

3. switching atomically to kernel stack

4. invoke interrupt handle (hardware)

5. return to program

Screen Shot 2022-09-25 at 11.26.28 PM.png

INTERRUPT SUMMARY

  1. device sends signal to APIC
  2. processor detects interrupt
  3. save recovery state and switch to kernel stack
  4. jump to interrupt handler table at appropriate vector and invoke interrupt handler
  5. restore user program

*syscalls are handled VERY similarly!

lec 4: systems programming processes and communication

Screen Shot 2022-09-26 at 9.49.26 AM.png

Screen Shot 2022-09-26 at 9.49.17 AM.png

process management API

Screen Shot 2022-09-26 at 11.04.50 AM.png

Input/Output in Linux

core tenants of the unix/IO interface

file descriptor

Screen Shot 2022-09-27 at 10.12.05 AM.png

lec 5: threads and the thread API

OS library

  1. improved programming API = minimizes glue code and simulates additional functionality
  2. performance = minimizes cost of syscalls

FDs to files

benefits of API

buffering

Screen Shot 2022-09-26 at 12.50.57 PM.png

Screen Shot 2022-09-26 at 12.54.06 PM.png

OS concurrency/parallelism

threads

Screen Shot 2022-09-26 at 6.00.49 PM.png

Screen Shot 2022-09-26 at 7.14.16 PM.png

user threads vs kernel threads

Screen Shot 2022-09-26 at 6.24.29 PM.png

pthreads

threads vs processes

Screen Shot 2022-09-27 at 9.50.24 AM.png

Screen Shot 2022-09-26 at 6.50.37 PM.png

Screen Shot 2022-09-26 at 6.49.57 PM.png

pthread_create()

Screen Shot 2022-09-26 at 6.53.12 PM.png

summary

lec 6: synchronization - concurrency and mutual exclusion

sockets vs pipes

interprocess communication: pipes

IPC across machines: sockets

socket functions

Screen Shot 2022-09-27 at 9.56.38 AM.png

connection setup over TCP/IP (Transmission Control Protocol)

dispatch loop

  1. RunThread();
    • load state into cpu, load environment, jump to PC
  2. ChooseNextThread();
  3. SaveStateOfCPU(curTCB);
  4. LoadStateOfCPU(newTCB);

internal events

external events

User Level Threading

Screen Shot 2022-09-26 at 8.50.14 PM.png

Screen Shot 2022-09-26 at 8.50.22 PM.png

Screen Shot 2022-09-26 at 8.51.29 PM.png

multiprocessing vs multiprogramming

Screen Shot 2022-09-26 at 8.52.30 PM.png

concurrent threads

lec 7: synchronization - concurrency, locks, atomic instructions

timer

threads

atomic operations

definitions

lec 8: synchronization - locks, semaphores

atomic operations

futex aka fast user-space mutex

semaphores

lec 9: synchronization - semaphores, monitors, read/writers

example of monitor (lock AND sem) implementation

Screen Shot 2022-09-27 at 10.28.33 AM.png

Reader/Writers problem

Screen Shot 2022-09-26 at 10.57.21 PM.png

monitors from semaphores

Screen Shot 2022-09-26 at 11.03.25 PM.png

extras

scheduling algorithms