Operating Systems 2017F Lecture 14

From Soma-notes
Revision as of 21:38, 28 October 2017 by Ssarazin (talk | contribs) (Created page with "==Review Notes== Definitions: - OS: A resource Manager that abstracts the hardware so that applications can get easy access to it. The OS facilitates resource sharing amon...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Review Notes

Definitions:

- OS: A resource Manager that abstracts the hardware so that applications can get easy access to it.  The OS facilitates resource sharing among concurrent programs.
- Kernel: The first program to launch when the computer boots.  The kernel has absolute power over the hardware; it manages and controls access to these resources.
- Process: A running program.  It has one or more threads and address space.
- Thread: A function that runs in the same memory space as other functions.
- Memory: A contiguous array of bytes.  Modern systems virtualize memory, mapping it to physical memory so it can be shared among processes.
- Interrupts: A mechanism used by the kernel that interrupts the CPU when other tasks are higher priority.
- Signals: Inter-process communications.  A mechanism used by the kernel and processes to communicate with one another.
- System Call: Specialized functions used by programs to request more resources from the kernel.
- File: A hierarchical name with a value mapping (Key/Value pair)
- Shell: Another program that is used to send system calls to the kernel or launch other programs.
- File system: A set of files grouped together with a common hierarchical root.
- Fragmentation: Variable sized memory allocation.
- Internal Fragmentation: Space wasted in an allocation.
- Concurrency: More than one thing happening at a time.
- Atomic Variables: Variables that guarantee a strict ordering of operations.
- Segmentation: Managing memory without paging.
- Segments: A variable sized block of memory that can be placed in different parts of the address space.
- Segfault: When a virtual address does not have a corresponding physical address.
- mmap: The virtual address range corresponds to the contents of a file or RAM.
- Concurrency: More than one thing is happening at the same time.

Creating a process:

  • fork() creates a process and execve() loads the binary to the new process.
    • returns a process id
      • pid > 0, parent process
      • pid < 0, error
      • pid = 0, child process
  • When a parent does not deal with its child processes they become zombies
  • If a parent dies before its children they become orphans that are re-parented by the OS
  • wait()
    • suspends the current process until one, some, or all of its children have terminated
    • wait() can be called anytime to check on the status of children

IO redirection:

  • >, direct to stdout
  • <, direct to stdin
  • |, connect the output of one process to the input of another process
  • when a process starts it is given file descriptors to stdout, stdin, and stderr

Inodes:

  • Contain information about the blocks corresponding to the contents of a file on disk, its owner, and the file access permissions.
  • A filename points to an inode
  • The inode count represents all of the files and folders on disk
  • Hard links create another name to the same inode number
    • Only point to files within the same file system
  • Symbolic links are files with their own inode
    • Can point to files in other partitions or file systems

Virtual Memory:

  • Every process receives a memory map with virtual addresses that correspond to physical addresses.

Memory Allocation Challenges:

  • Need to have a contiguous address range
  • Data Structures can not be moved once allocated
  • Memory is constantly allocated and deallocated

Solution to these challenges:

  • Use fixed size chunks that can be stored anywhere
    • Called a page in memory or a block on disk
    • Sizes are always a power of 2 because addresses are indexed in bits
    • The benefit: it removes the limitations on array sizes.
    • Use a table to map virtual memory to physical memory -- called a page table
    • In a 32 bit system: the top 20 bits are the page locations and the lower 12 bits are the page offset

Concurrency:

  • Challenge: keeping the shared state consistent; want deterministic behavior from concurrent computations
  • Solution: Need mechanisms that bypass the memory hierarchy.
    • Use filesystem locking primitives -> atomic variables -> semaphores
    • Use signals to synchronize the shared state

Segmentation:

  • The physical address can be found by adding the segment register to the offset.