I : stime allows superuser to set a global kernel variable to a value that gives current time
usage stime(pvalue) where pvalue points to a long integer that gives seconds from Jan 1 1970
important clock interrupt handler increments the the kernal variable once a second
II : time retrievs the time as set by stime
usage time(tloc) where tloc points to a location in the user process for the return value
important commands such as date use time to determine current time
III : times retrieves the cumulative times that the calling process spent executing in
user mode
kernel mode
retrieves the cumulative times that all zombie children had executes in
user mode
kernel mode
usage times(tbuffer)
struct tms*buffer; struct tms { time_t tms_utime // user time
time_t tms_stime // kernel time
time_t tms_cutime // children user time
time_t tms_cstime // children kernel time
times returns the elapsed time “from an arbitary point in the past”
(usually the boot time)
IV : Alarm is used to set an alarm to remind the process of something while it is working on somethings else
Sleep on the other hand also wakes up a process but in that case process is not active. In Alarm system call the process can continue to run
Example : 42 signal(SIGALRM,wakeup);
43 alarm(10);
Example for times:
18 pt1=times(pb1);
19 for(i=0;i less than 3; i++)
20 if(fork()==0)
21 child(i);
22
23
24 for(i=0;i is less than 3 ;i ++) // why do we need this loop ??
25 wait((int *)0);usage stime(pvalue) where pvalue points to a long integer that gives seconds from Jan 1 1970
important clock interrupt handler increments the the kernal variable once a second
II : time retrievs the time as set by stime
usage time(tloc) where tloc points to a location in the user process for the return value
important commands such as date use time to determine current time
III : times retrieves the cumulative times that the calling process spent executing in
user mode
kernel mode
retrieves the cumulative times that all zombie children had executes in
user mode
kernel mode
usage times(tbuffer)
struct tms*buffer; struct tms { time_t tms_utime // user time
time_t tms_stime // kernel time
time_t tms_cutime // children user time
time_t tms_cstime // children kernel time
times returns the elapsed time “from an arbitary point in the past”
(usually the boot time)
IV : Alarm is used to set an alarm to remind the process of something while it is working on somethings else
Sleep on the other hand also wakes up a process but in that case process is not active. In Alarm system call the process can continue to run
Example : 42 signal(SIGALRM,wakeup);
43 alarm(10);
Example for times:
18 pt1=times(pb1);
19 for(i=0;i less than 3; i++)
20 if(fork()==0)
21 child(i);
22
23
24 for(i=0;i is less than 3 ;i ++) // why do we need this loop ??
26 pt2=times(pb2);
27
28 printf("\n Parent real %ld user %ld sys %ld",pt2-pt1,
29 pb2.tms_utime-pb1.tms_utime,
30 pb2.tms_stime-pb1.tms_stime);
31 printf("\n Parent child user %ld sys %ld",
32 pb2.tms_cutime-pb1.tms_cutime,
33 pb2.tms_cstime-pb1.tms_cstime);
Function of Clock Interrupt Handler
restart the clock c
schedule invocation of internal kernel functions f
provide execution profiling p
gather system and process accounting stats s
keep track of time t
send alarm signals to process on request a
periodically wakeup the swapper process s
control the process scheduling p
p2as2t cf
past coffee
No comments:
Post a Comment