/[dynamips]/upstream/dynamips-0.2.6-RC3/ptask.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /upstream/dynamips-0.2.6-RC3/ptask.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

upstream/dynamips-0.2.6-RC1/ptask.c revision 2 by dpavlin, Sat Oct 6 16:03:58 2007 UTC upstream/dynamips-0.2.6-RC2/ptask.c revision 3 by dpavlin, Sat Oct 6 16:05:34 2007 UTC
# Line 34  static ptask_id_t ptask_current_id = 0; Line 34  static ptask_id_t ptask_current_id = 0;
34  /* Periodic task thread */  /* Periodic task thread */
35  static void *ptask_run(void *arg)  static void *ptask_run(void *arg)
36  {  {
37       pthread_mutex_t umutex = PTHREAD_MUTEX_INITIALIZER;
38       pthread_cond_t ucond = PTHREAD_COND_INITIALIZER;
39    
40     ptask_t *task;     ptask_t *task;
41    
42     for(;;) {     for(;;) {
# Line 41  static void *ptask_run(void *arg) Line 44  static void *ptask_run(void *arg)
44        for(task=ptask_list;task;task=task->next)        for(task=ptask_list;task;task=task->next)
45           task->cbk(task->object,task->arg);           task->cbk(task->object,task->arg);
46        PTASK_UNLOCK();        PTASK_UNLOCK();
47        usleep(ptask_sleep_time*1000);  
48          /* For testing! */
49          {
50             struct timespec t_spc;
51             m_tmcnt_t expire;
52    
53             expire = m_gettime_usec() + 2000;
54    
55             pthread_mutex_lock(&umutex);
56             t_spc.tv_sec = expire / 1000000;
57             t_spc.tv_nsec = (expire % 1000000) * 1000;
58             pthread_cond_timedwait(&ucond,&umutex,&t_spc);
59             pthread_mutex_unlock(&umutex);
60          }
61    
62          /* Old method... */
63          //usleep(ptask_sleep_time*1000);
64     }     }
65    
66     return NULL;     return NULL;

Legend:
Removed from v.2  
changed lines
  Added in v.3

  ViewVC Help
Powered by ViewVC 1.1.26