Visible Operating Systems - Operating Systems - Lecture Notes, Study notes of Operating Systems

Main points of this lecture are: Visible Operating Systems, Process Life and Death, Creating Image, Running Image, External Symbols, File's Symbol Table, Dynamic Linker, Concept of Sharing, Executing Process, Shared Memory, Process Sharing Behavior

Typology: Study notes

2012/2013

Uploaded on 04/23/2013

ashalata
ashalata 🇮🇳

3.8

(18)

106 documents

1 / 34

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
We've studied what a process is.
and know that it has a limited view of the OS,
and has one of a limited number of states.
So far,
We'll explore a process's world in linux,
how a process is born and dies,
and how it requests services from the operating
system.
In this lecture,
Tuesday, September 28, 2010
3:50 PM
The_Visible_OS Page 1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22

Partial preview of the text

Download Visible Operating Systems - Operating Systems - Lecture Notes and more Study notes Operating Systems in PDF only on Docsity!

We've studied what a process is. and know that it has a limited view of the OS, and has one of a limited number of states. So far, We'll explore a process's world in linux, how a process is born and dies, and how it requests services from the operating system. In this lecture, Process life and death Tuesday, September 28, 2010 3:50 PM Docsity.com

From file.c to a.out from a.out to running image Two steps Creating a process Thursday, September 23, 2010 1:10 PM Docsity.com

#include <stdio.h> main() { printf("hi there\n"); } My program Tuesday, September 25, 2012 4:44 PM Docsity.com

file.o contains external symbols and defined symbols libc.a contains .o files for all library functions. Process of linking: scan libc.a for symbols declared external by file.o, load appropriate .o files. ar t /usr/lib/libc.a # lists all the .o files in libc.a A window into libc.a: "ar" nm file.o # lists the file's symbol table. A window into linking: "nm" From a.out to running image Thursday, September 23, 2010 1:13 PM Docsity.com

q The concept of sharing Tuesday, September 27, 2011 4:41 PM Docsity.com

fork(2) creates a copy of the current process (your shell) run ld.so to load process into memory. Load a.out followed by libc.so (and perhaps other dynamic libraries) Link external symbols in a.out to defined symbols in libc.so Start execution of new process. exec(2) replaces that copy with the new process: When you try to run a process: Executing a process Thursday, September 23, 2010 1:13 PM Docsity.com

which is a stub that just calls the printf shared code in libc.so. so that your program only has to load a tiny subroutine in order to access the shared space! Calling printf loads printf.o in libc.a, Designing for shared memory Thursday, September 23, 2010 2:00 PM Docsity.com

Read-only Shared among every running instance of the program Program is in the text segment Read-write Not shared. Data is in the stack, heap, global segments. Process sharing behavior If 100 students are running emacs, there is one copy of its text segment! Process sharing behavior Thursday, September 22, 2011 3:41 PM Docsity.com

Every Microsoft application comes with its own DLLs (Dynamically Linked Libraries, Microsoft's version of .so's) One application can overwrite the DLLs of another. Result: execution errors! Exact same problem with .so's in linux. But: my students have verified that -- at least -- RedHat has its act together. This has behavioral ramifications "DLL Hell" Thursday, September 22, 2011 3:58 PM Docsity.com

Every process other than the first one ( init , process with process-id=1) is the child of some other process (that called fork(2) to create it).

Every process reports its exit code to its parent, who must " reap " that code.

If a parent is remiss in reading the code, a process becomes a zombie , i.e., the living dead.

Zombie processes can clutter a process table and bring a system to its knees.

Process life and death Process life and death Monday, September 18, 2006 2:39 PM Docsity.com

Example: running a "cat" command in the foreground: http://www.cs.tufts.edu/comp/111/examples/The_Visible_OS/wait1.c Example: running a "cat" command in the foreground with explicit wait: http://www.cs.tufts.edu/comp/111/examples/The_Visible_OS/wait2.c Example: running a "cat" command in the background with implicit wait: http://www.cs.tufts.edu/comp/111/examples/The_Visible_OS/wait3.c Example: running a user-typed command in the foreground without arguments: http://www.cs.tufts.edu/comp/111/examples/The_Visible_OS/shell.c Example: running a user-typed command in the background without arguments: http://www.cs.tufts.edu/comp/111/examples/The_Visible_OS/shell2.c Creation examples Friday, September 23, 2011 10:58 AM Docsity.com

typing ./a.out in the shell is an explicit wait. typing ./a.out & in the shell is a background execution. The point of this discussion: The point Tuesday, September 27, 2011 5:06 PM Docsity.com

its environment. all open files. (There is a sneaky trick in the pager, called "copy on write", that accomplishes this cloning in O(1). More about that later.) The whole running program gets copied, including The parent gets the pid of the child from fork(). The child gets a 0 (indicating that it is not a parent to anything). Both copies then proceed to execute independently. What exactly happens during a fork()? What exactly happens during a fork()? Friday, September 23, 2011 11:00 AM Docsity.com

Environment is preserved. Open files stay open. All of memory is replaced. What happens during an exec? File buffers are not flushed. The buffers themselves are erased! Buffered writes can be lost. In particular: What happens during an exec? Friday, September 23, 2011 11:04 AM Docsity.com