Lecture 1


There are 5 project grace days, which are classic CS style grace days

AT&T Archives: The UNIX Operating System

OS Challenges

Process

Stack & Heap

xv6 Process States

proc.h: enum procstate {UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE};

System Calls

Processes

A process is an instance of a program, it is instantiated by being executed, and it runs with limited rights. They are started by opening an exectuable file

Differences between programs and processes:

There are two main components of a process:

  1. Address space, includes
    • Code
    • Data
    • Stack
    • Heap
    • Kernel stack
  2. State: includes
    • Managed by the process control block or PCB,
    • Resides in the kernel address space
    • Includes the following components:
      • Registers
      • Program counters.
      • A list of files that are currently opened

Address Space Abstraction

Protection via process isolation is one the key principles of building reliable systems is isolation of processes in order to provide protection.

Address space is an abstraction of physical memory created in order to create a sandbox for each process. Each process has its own little playful sandbox where it has its own code, data, and stack.

This is a joint effort by hardware and the operating syystem.

The operating system, for its own protection, has its own address space

Process Address Space

Invoking functions

The Computer Systems textbook has a good section on translating a function call. There's also good material about this in your CSCI 353 textbook: "Computer Systems: A Programmer's Perspective"

Untangling stack and heap, and static vs. dynamic memory. A stack pointer, local variables are stored on the stack, a data structure which supports push and pop operations in a LIFO order. Called functions are pushed by the compiler, which is called the frame.

States of a process

In xv6, the states of a process are as follows, as declared in proc.h

`enum procstate {UNUSED, EMBRYO, SLEEPING, RUNNABLE, RUNNING, ZOMBIE};

  1. Embrio
  2. Runnable
  3. Running
  4. Sleeping
  5. Zombie

More commonly, those processes are referred to as, in order:

A zombie state is a special case, when a process terminates because there are no more processes to be executed, but the process remains in the PCB table. This is commonly found when a parent created a child process, and needs to follow the state of the child process for its own execution.

Questions

Question 1

Apple is releasing a car. Will it have windows?

Question 2

Which of the following tasks would require OS support?

  1. Input a character from the keyboard: yes
  2. Invoke a high-level matrix multiplication operation: no
  3. Allocate n bytes of memory for a new data structure: yes
  4. Load a program into memory: yes
  5. Change the layout of a document: no
  6. Call a library function: yes
  7. Call a function defined within the current program: no
  8. Exit the current program: yes
  9. Sleep for n seconds: yes

Question 3

Think about the difference between system reliability and availability:

  1. Give an example of a system which is reliable but not available The train station by my house has trains that always arrive directly on time, but only arrive a few times a day. They leave shortly thereafter, so the majority of the time, there is no train availbale to those sitting at the train station.
  2. Give an example of a system which is available but not reliable When renting a place to stay through AirBnB, you can be assured that you will be able to find a place to stay, whenever it is you want to stay there. Upon your arrival, however, you may find your appointment is abruptly cancelled, or your stay is cut short by an emergency maintenance.

Question 4

  1. Why do the stack and the heap grow in opposite directions? It optimizes the amount of space used without overlap.
  2. Which is faster to access: the stack or the heap? The stack, because it's just a derefencing of a pointer. The heap, on the other hand, has a more complex implementation, which involves a higher overhead, from actions such as allocating memory and deallocating memory.

Question 5

Question 6

True or false:

  1. An OS uses a PCB to represent a process:
    • false: the PCP represents metadata about a process.
  2. The PCB is created by the process when execution starts
    • false: it is created by the operating system
  3. The PCB is becomes part of the process being executed
    • false: it is part of the operating system, or else a process could modify its own process control.
  4. Two processes can be executing the same program:
    • true

Question 7

Missing...

Question 8

Part A:

Part B: