COMP 3000 2011 Week 2 Notes

From Soma-notes

UNIX Basics

Process: abstractraction for keeping programs separate

Program Image: binary program written to disc; creates a running program in memory

Core Dump: what you get when a program crashes if you were lucky and enabled it--takes the core image--all in memory--and writes it to disc

Wait: parent process claiming return value of child

Shell (system calls): interface for interacting with the system--managing resources and programs; an interface to do system calls

Permission (file system): in UNIX everything fits into a single hierarchy

Links: using pointers to refer to files

  • Inode: the index node is the intermediate name to access'refer to multiple files. If you change one file, it is reflected everywhere. You can't delete a file in UNIX, you can only unlink it. The system will know to delete a file when all the links to an inode (reference count) is zero. The metadata for a file and permissions are all located in the inode.

Application vs. Process:

  • An application can run multiple processes
  • Process can run without our knowledge and in the background all the time
  • There is only one copy of a program on disc even if you're running multiple processes (i.e. multiple copies of the program are open). In other words, 5 copies of a program don't take up 5 times the memroy.

Virtual, Resident and Shared Memory

  1. Virtual: all of a program's code and data--how much memory the program thinks it has
  2. Resident: amount of memory used in physical memory (RAM)
  3. Shared: memory shared with other processes. This is usally in the form of libraries (UNIX's response to the linking problem--having multiple copies of a function in memory, which is just a waste of space).

Fork vs. Exec ve

Fork: Calling fork will preserve the parent process (the original process ID) and create a child (new process)--a copy of the program binary (same binary but new process)

Exec ve: takes a file and loads the program binary but doesn't make a new process--it uses the process that made the exec ve call (i.e. the program that calls exec ve kills itself and the new program binary is loaded)

Zombie Process: parent process still needs to claim the return value of the child process. To kill a zombie process you need to kill the parent.