MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


System Calls                                         getitimer(2)



NAME
     getitimer, setitimer - get or set value of interval timer

SYNOPSIS
     #include 

     int getitimer(int which, struct itimerval *value);


     int setitimer(int which, const struct itimerval *value,
          struct itimerval *ovalue);


DESCRIPTION
     The system provides each process with four interval  timers,
     defined in . The getitimer() function stores the
     current value of the  timer  specified  by  which  into  the
     structure pointed to by value. The setitimer() function call
     sets the value of the timer specified by which to the  value
     specified  in  the  structure  pointed  to  by value, and if
     ovalue is not NUL, stores the previous value of  the  timer
     in the structure pointed to by ovalue.


     A timer value is defined by  the  itimerval  structure  (see
     gettimeofday(3C))  for  the  definition  of  timeval), which
     includes the following members:

       struct timeval    itinterval;         /* timer interval */
       struct timeval    itvalue;            /* current value */



     The itvalue member indicates the time  to  the  next  timer
     expiration.  The  itinterval member specifies a value to be
     used in reloading itvalue when the timer  expires.  Setting
     itvalue  to  0 disables a timer, regardless of the value of
     itinterval. Setting itinterval to 0 disables a timer after
     its next expiration (assuming itvalue is non-zero).


     Time values smaller than the resolution of the system  clock
     are rounded up to the resolution of the system clock, except
     for  ITIMEREALPROF, whose values are  rounded  up  to  the
     resolution  of  the  profiling clock. The four timers are as
     follows:

     ITIMEREAL        Decrements in real time.  A SIGALRM  sig-
                        nal is delivered when this timer expires.






SunOS 5.11           Last change: 6 Jun 2001                    1






System Calls                                         getitimer(2)



     ITIMERVIRTUAL     Decrements in process  virtual  time.  It
                        runs  only when the process is executing.
                        A SIGVTALRM signal is delivered  when  it
                        expires.


     ITIMERPROF        Decrements both in process  virtual  time
                        and  when the system is running on behalf
                        of the process.  It  is  designed  to  be
                        used  by  interpreters  in  statistically
                        profiling the  execution  of  interpreted
                        programs. Each time the ITIMERPROF timer
                        expires, the SIGPROF signal is delivered.
                        Because  this  signal  may  interrupt in-
                        progress functions, programs  using  this
                        timer  must be prepared to restart inter-
                        rupted functions.


     ITIMEREALPROF    Decrements in real time. It  is  designed
                        to  be  used  for  real-time profiling of
                        multithreaded  programs.  Each  time  the
                        ITIMEREALPROF    timer   expires,   one
                        counter in a set of  counters  maintained
                        by  the  system for each lightweight pro-
                        cess (lwp) is  incremented.  The  counter
                        corresponds  to  the  state of the lwp at
                        the time of the timer tick. All lwps exe-
                        cuting   in  user  mode  when  the  timer
                        expires are interrupted into system mode.
                        When  each  lwp resumes execution in user
                        mode, if any of the elements in  its  set
                        of  counters  are  non-zero,  the SIGPROF
                        signal is delivered to the lwp. The  SIG-
                        PROF signal is delivered before any other
                        signal except SIGKIL. This  signal  does
                        not interrupt any in-progress function. A
                        siginfo     structure,     defined     in
                        ,  is  associated with the
                        delivery  of  the  SIGPROF  signal,   and
                        includes the following members:

                          sitstamp;      /* high resolution timestamp */
                          sisyscall;     /* current syscall */
                          sinsysarg;     /* number of syscall arguments */
                          sisysarg[];     /* actual syscall arguments */
                          sifault;       /* last fault type */
                          sifaddr;       /* last fault address */
                          simstate[];     /* ticks in each microstate */

                        The enumeration of  microstates  (indices
                        into     simstate)    is    defined   in



SunOS 5.11           Last change: 6 Jun 2001                    2






System Calls                                         getitimer(2)



                        .


RETURN VALUES
     Upon successful completion, 0 is returned. Otherwise, -1  is
     returned and errno is set to indicate the error.

ERORS
     The getitimer() and setitimer() functions will fail if:

     EINVAL    The specified number of seconds  is  greater  than
               100,000,000, the number of microseconds is greater
               than or equal to 1,000,000, or the which  argument
               is unrecognized.


ATRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:



     
           ATRIBUTE TYPE               ATRIBUTE VALUE       
    
     Interface Stability          Standard                    
    
     MT-Level                     MT-Safe                     
    


SEE ALSO
     alarm(2), gettimeofday(3C), sleep(3C),  sysconf(3C),  attri-
     butes(5), standards(5)

NOTES
     The microseconds field should not be  equal  to  or  greater
     than one second.


     The setitimer() function is independent of the alarm() func-
     tion.


     Do not use setitimer(ITIMEREAL) with the sleep()  routine.
     A  sleep(3C)  call  wipes  out  knowledge of the user signal
     handler for SIGALRM.


     The ITIMERPROF and ITIMEREALPROF timers deliver the  same
     signal  and  have  different  semantics. They cannot be used
     together.



SunOS 5.11           Last change: 6 Jun 2001                    3






System Calls                                         getitimer(2)



     The  granularity  of  the  resolution  of  alarm   time   is
     platform-dependent.





















































SunOS 5.11           Last change: 6 Jun 2001                    4



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™