Operating Systems 2017F Lecture 14: Difference between revisions

From Soma-notes
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..."
 
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
==Video==
The video from the lecture given on Oct. 31, 2017 [http://homeostasis.scs.carleton.ca/~soma/os-2017f/lectures/comp3000-2017f-lec14-31Oct2017.mp4 is now available].
==Review Notes==
==Review Notes==


Line 23: Line 27:
  - mmap: The virtual address range corresponds to the contents of a file or RAM.
  - 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.
  - Concurrency: More than one thing is happening at the same time.
**********************************************************
Professor's explanations of assignment 1 and 2 :
What does stat really return?
Inode number, directry , number if hard links
If you have a file, you basically hard link, and it is basically a reference count.
 Manual page for stat() , man stat(2)
o Ctime: modification made by the inode,
o Everytime you read a file, you write to a file system , and it is expensive and not good for you device
 Device files are not real file, they are name spaces to access other things, like terminal, screen video.
o Ex: dev random, is not really a file, it just produces bits
o You have to compare which device they are pointing to and if they return the same major and minor ID’s then they are equal
Q10 Review :
 Only if it is waiting you wake it up and set the flag into 1
o Affect = kicks you out
o Generating a lot of signals to the consumer
 A signal should happen occasionally
o Kill -1 , you kill every process . don’t get it ask ?
o Maybe you should set the consumer to 0 and see what happens , in 3000pc
 Why does the program deadlocks when request a large amount of numbers ?
o signals aren’t always delivered , they sometimes get lost, but generlay they get there unless you send various amount of signals
 theory about time:
o gettimeofdat: man gettimeofday


Creating a process:
Creating a process:

Latest revision as of 04:59, 4 November 2017

Video

The video from the lecture given on Oct. 31, 2017 is now available.

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.

Professor's explanations of assignment 1 and 2 :

What does stat really return? Inode number, directry , number if hard links If you have a file, you basically hard link, and it is basically a reference count.  Manual page for stat() , man stat(2) o Ctime: modification made by the inode, o Everytime you read a file, you write to a file system , and it is expensive and not good for you device  Device files are not real file, they are name spaces to access other things, like terminal, screen video. o Ex: dev random, is not really a file, it just produces bits o You have to compare which device they are pointing to and if they return the same major and minor ID’s then they are equal Q10 Review :  Only if it is waiting you wake it up and set the flag into 1 o Affect = kicks you out o Generating a lot of signals to the consumer  A signal should happen occasionally o Kill -1 , you kill every process . don’t get it ask ? o Maybe you should set the consumer to 0 and see what happens , in 3000pc  Why does the program deadlocks when request a large amount of numbers ? o signals aren’t always delivered , they sometimes get lost, but generlay they get there unless you send various amount of signals  theory about time: o gettimeofdat: man gettimeofday


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.