Operating Systems 2017F Lecture 3

From Soma-notes
Revision as of 00:27, 4 October 2017 by Jamesklau (talk | contribs)
Jump to navigation Jump to search

Video

Video from the lecture given on September 14, 2017 is now available.

Code

Code and files from the lecture (captured as they were at the end) are available here.


Notes

Commands

  • -wall: show all warning
  • less: allow screen navigation, hit q to quit

What is fork?

  • Fork creates a new program but contains the same code (call the clone system call) and only argv[] and envp[] passed on to the new born program

What Happen to the child process after the parent process died?

  • Every child process must have a currently running parent. When the parent process die, kernel collect the dead body(return value) and re-parent the process
  • In the demo showed in class, “system d user” became its new parent
    • Use command "Pstree" to show process hierarchy

What is zombie process?

  • When a process die it become 'zombie' (s = sleep, z = zombie)
  • We can use wait to be a 'good' parent

How to load a new binary manually

  • Use the execve command.
    • We can fork child process to handle dangerous task (“Suicide Squad”), or handle all incoming request

Manipulating environment variables

  • argc tells the number of argument in command line, while argv[] contains the actual command obtained in the command line