Unix-v5 Process Structure. A process is an entity which is created by the operating system and consists of a sequence of bytes which is interpreted by the CPU as Machine instruction. Data Stack.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
A process is an entity which is created by the operating system and consists of a sequence of bytes which is interpreted by the CPU as
Process consists of 3 regions. Region is a contagious area of the virtual address space
Page table address Virtual address no of pages
Per process Region table
Page table address Virtual address no of pages
Allocate a new region during fork, exec, shmget (shared memory) system calls.
remove region from linked list of free regions;
assign the free region into active list and lock the region
mark the region type to be shared or private.
if (inode pointer is not null)
increment inode reference count to prevent other processes
from removing the inode when executes unlink.
place region on linked list of active regions.
return locked region
In case of more memory required, kernel allocate new page table or expand existing page table. Allocate physical memory for pages on systems do not support demand pages.
exec system calls load a text of size 7k into memory with a gap of 1K bytes in the beginning. The page containing address 0 will be protected such that access 0 will incur page fault and abort.
The kernel detaches regions in the exec, exit, and shmdt (detach shared memory).
Input : pointer to per process region table.
decrement process size;
Decrement region reference count;
release per process region table;
if (region reference count is 0)
free region (algorithm freereg);
Parent user stack
child user stack
pid =123 gid =456
pid =555 gid =555
pid =666 gid =666
Process group leader
pid =456 gid =456
. The kernel uses a group id to identify the set of processes which receive common signal. If process A sends a signal kill (0,SIGINT), it will be caught by all processes which have the same gid number(e.g. B,C).
Create 4 child processes. Even number processes has the same group id like parent. Processes created during odd iterations of the loop reset their process group number. When kill signal is sent it will terminate the even number while the odd will continue to execute.
Input : none
Output: to parent process, child pid, to child process, 0
allocate process table entry, allocate PID number;
copy data from parent process table slot into new child slot;
copy data region of parent process (dupreg, attachreg);
copy user stack region of parent process, (dupreg, attachreg);
share text for parent process (attachreg);
increment inode count for current directory and changed root;
increment file counts in file table;
if (executing process is parent process)
change the child state in memory into “ready to run”
return (child PID);
else // the child process is executing
Process is terminated by executing exit system call. An exiting process will enter zombie state, relinquishes its resources, and dismantle its context except for its slot in the process table.
Input: return code for parent process
if (process is a group leader)
send an hangup signal to all members of process group
reset process group for all members to 0
close all open files (internal version of close)
release current directory (iput)
release current changed root, if exists (iput);
free region; (freereg)
make process state zombie;
assign parent to all children processes to be init (PPID = 1);
send death of child (SIGCHLD)to parent process
if (child process in zombie state)
// init remove child from process table
send death of child (SIGCHLD) to parent
Processes on UNIX are identified by a unique ID number and by group id number. Both ids are saved in the process table.
exec invoke another program and overlay the memory space of the process with the copy of the executable file.
Input : file name
environment variable list
get file inode (namei)
verify file executable, user has permission to execute
read file headers, check that it is load module
copy exec parameters from old address space to system space
for (every region attached to the process)
detach all regions (detachreg)
for (every region specified in load module)
allocate new region (allocreg)
attach the region (attachreg)
load region to memory if appropriate (loadreg)
copy exec parameters into new user stack region
initialize registers (e.g. program counter & stack register)
release inode of file (iput)
if (fork () == 0)
Section 1 Header
Section n Header