Systemprog
Systemprog
PROCESS:
program in execution ;
------------------------------
if two instances of a program can share the same virtual memory address at the same
time even if te data is different. --> run the program in two different variables
passing from command line in two terminals at same time
---------------------
process states
interrupt
admit <-- exit
start --> ready --> running --> terminated
| scheduler dispatch|
wait ----------------------
----------------------------------------------------------------------
int fork(void)
1) int fork(void)
description: ceate the child process --> return the intiger process id of the new
process
------------------
the program is laded in the calling process address space and the old program is
over and no longer available
---------------
void exit(int returnCode)
---------------------
it is basically a calling process to wait until any process created by the call and
process exits
--------------------------
THREADS: pthreads
baisc unit of CPU utilization ; shares resources with other threads in the same
process
there is a lot of overhead and it takes a lot of cpu clock cycles to crete and
destroy threads within process
----------------------------
int pthread_create(..)
pthread_t *myThread;
pthread_create(myThread..);
--------------
int pthread_join(...)
a very common way to wait for threads to finish is if you have a program that
creates 10 threads and you want towait for all the threads to complete executing
before you move on with your main code, use below for loop
void pthread_exit()