
Process
Process = program in execution
- One or more threads.
- Can communicate through pipes, signals, networks, files.
Process descriptor
- Each process has its Process Descriptor, which is used to keep track of the process in memory
- Stores PID, state, parent process, children, registers, address space information, open files
- Process information is usually stored in the so called Process Table, i.e. an array of PD
Three states model
- Running : execution, process is using the CPU.
- Ready : process can be executed but is temporarily waiting, CPU is used by another process.
- Waiting : process can’t be executed; it is either blocked because waiting for an external event (e.g. I/O, interrupt from another process) or because scheduler assigned CPU to others.
Code in C
|
|
- getpid(): returns the process ID of the calling process.
- getppid() : returns the process ID of the parent of the calling process.
- getgid() : returns the group ID of the calling process
- getuid() : returns the user ID of the calling process
Creat
|
|
Remarks:
- p == 0 (Child process)
- p == -1 (Error)
- p > 0 (Parent process)
Get ID
|
|




近期评论