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 />
Process<br />
An instance of program being executed by operating system. A new process is created by issuing <strong>the</strong> fork<br />
system call. A program may be executed by many processes at same time.<br />
System Calls<br />
The <strong>Unix</strong> kernel provides a limited number (60-200) of direct entry points for services from <strong>the</strong> kernel.<br />
The standard <strong>Unix</strong> C library provides a C interface to each system call or function.<br />
Most system calls return -1 if an error occurs, or a value >= 0<br />
A global integer variable errno is provided by <strong>the</strong> C interface. The header file contains <strong>the</strong> names<br />
and values of <strong>the</strong>se error numbers.<br />
Some system calls return a pointer to a structure of information, e.g. stat and fstat system calls.<br />
! C Start-up Function<br />
main()<br />
{<br />
printf ("hello world\n") ;<br />
exit(0);<br />
/* flush standard I/O buffers<br />
& terminate */<br />
}<br />
user functions<br />
or library<br />
call | | return<br />
user' s main<br />
function<br />
user<br />
call | | return<br />
C startoff<br />
routine<br />
exit<br />
C exit<br />
routine<br />
exit<br />
C exit<br />
routine<br />
program invocation: exec<br />
system call<br />
kernel<br />
! Argument List<br />
Whenever a program is executed, a variable-length argument process. The argument list is passed to <strong>the</strong> process.<br />
The argument list is an array of pointers to character strings (maximum size of 5120 bytes).<br />
echo hello world<br />
main (argc, argv)<br />
int argc; char *argv[];<br />
{…}<br />
argv ------ argv[0] ------ echo\0<br />
------ argv[1] ------ hello\0<br />
------ argv[2] ------ world\0<br />
! Environment List<br />
main (argc, argv, envp)<br />
int argc; char *argv[]; char *envp[];<br />
{<br />
int i;<br />
for (i = 0; envp [i] != (char *) 0; i++)<br />
printf("%s\n", envp[i]);<br />
exit(0) ;<br />
}<br />
HOME=/user1/staff/neville<br />
SHELL=/bin/ksh<br />
TERM=vtl00<br />
109