   Timing a fork
  I''m working on timing the length of time it takes to fork a process on a *nix system in C (I''m running the program on Red Hat and Solaris here at school).I''ve searched around, looking for sub-second timing. I found a gettimeofday() that is in <sys/time.h>, but I''ve heard it is deprecated. I''ve found a clock_gettime(), which is SUPPOSED to be in <time.h> but it''s not working (I get "undefined reference to ''clock_gettime''", even though I have time.h included).I''ve searched here, but mostly I''ve found windows solutions, and obviously as I stated before, I need *nix solutions.Is gettimeofday() recommended? I don''t need to be incredibly accurate, I just need sub-second timing.my code, pretty simple. this still has the calls to clock_gettime that aren''t working.   include <sys/types.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <time.h>#define BILLION  1000000000Lint main(void){  pid_t parent_id;  struct timespec start, stop;  double accum;  clock_gettime(CLOCK_REALTIME, &start);  parent_id=getpid();  /* begin timing */  if( fork() < 0 ){    printf("fork error\n");    exit(1);  }  if(getpid()!=parent_id){    clock_gettime(CLOCK_REALTIME, &stop);    accum=(stop.tv_sec-start.tv_sec) + (double)(stop.tv_nsec - start.tv_nsec)/(double)BILLION;    printf("%d\n",accum);  } /* end timer */  exit(0);  return 0;}This red hat system that I am working on is bugging me (it''s not mine, it''s a student server), because at one point I didn''t reallize I wasn''t including stdio.h, but I was still able to printf. Weird. 
  So, nobody cares to answer? ;  I didn''t know gettimeofday() was deprecated. Sources ? ;  We did a similar project in school, our teacher recommended we use gettimeofday(). ;  Your libc must up-to-date enough (not sure exactly how much is "enough") for clock_gettime to be included and you must link to librt to use it.I don''t know that gettimeofday is explicitly deprecated, but I do know that the clock_* family of functions was meant to replace both it and settimeofday.   ;  thanks. works now, getting an average of 150 milliseconds. 