Lecture2 ProcessAndProcessAPIs
Lecture2 ProcessAndProcessAPIs
code
static data
CPU heap Memory
stack
Process
code Create
static data
Disk Program
A Process has …
• A memory that the process uses to reference its instructions
and data
1. Code Segment containing instructions
2. Data Segment containing heap data (malloc)
3. Stack containing parameters, local variables, return address, etc.
of functions
4. Process Descriptor (keep Process Control Block) – stored in the
kernel space and can only be accessed in kernel mode execution
1 2 3 4
Sample Problems
If we just run a program, how can the OS make sure the program
doesn’t do things that we don’t want, while still running it
efficiently?
– int pipe(int fd[2]); fd[0] is set up for reading, fd[1] for writing