You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Processes I<br />
USER=neville<br />
PATH=/userl/staff/joe/bin:/usr/local/bin:/bin:/usr/bin:<br />
main (argc, argv)<br />
int argc; char *argv[];<br />
{<br />
int i;<br />
extern char **environ;<br />
for (i = 0; environ[i] != (char *) 0; i++)<br />
printf("%s\n", environ[i]);<br />
exit(0);<br />
}<br />
main ()<br />
{<br />
char *ptr, *getenv();<br />
if ( (ptr = getenv("HOME")) == (char *) 0)<br />
printf ("HOME is not defined\n ") ;<br />
else<br />
printf("HOME=%s\n", ptr);<br />
exit(0);<br />
}<br />
The argument list, environment pointers and character strings pointed to are in <strong>the</strong> data space of <strong>the</strong> process. The<br />
process can modify <strong>the</strong>se but this has no effect on <strong>the</strong> parent process.<br />
The only value passed by <strong>the</strong> terminating process to its parent process by <strong>the</strong> operating system is <strong>the</strong> 8-bit argument<br />
to <strong>the</strong> exit function.<br />
The parent and child can exchange information using a disk file or by interprocess communication. A process can<br />
modify its environment to affect any child processes it created.<br />
! Process user context<br />
kernel context<br />
stack<br />
kernel data<br />
heap<br />
uninitialized data<br />
initialized readwrite<br />
data<br />
initialized readonly<br />
data<br />
text<br />
read from program file<br />
when program is executed<br />
user context<br />
text<br />
data<br />
heap<br />
stack<br />
portion of address space accessible to <strong>the</strong> process while it is running in user mode.<br />
<strong>the</strong> actual machine instruction that are executed by hardware. Often set readonly<br />
so that process cannot modify its instructions. It is read into memory from disk, unless as<br />
supports shared text and it already is executing.<br />
contains <strong>the</strong> program's data<br />
- initialized read-only – ro while program executing. e.g. literal strings; not supported on many<br />
<strong>OS</strong>s<br />
- initialized read-write – modified during execution uninitialized - set to zero before process<br />
starts, advantages – save disk space & time to read data<br />
used to allocate data space dynamically to <strong>the</strong> process while <strong>the</strong> process is running.<br />
used dynamically while process is running to contain stack frames that are used by <strong>the</strong><br />
programming language. Stack frames contain <strong>the</strong> calling arguments and return addresses.<br />
kernel context is maintained and accessible only to <strong>the</strong> kernel. It contains information that <strong>the</strong> kernel needs to<br />
keep track of <strong>the</strong> process and to stop and restart <strong>the</strong> process while o<strong>the</strong>r processes are allowed to<br />
execute.<br />
110