のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

wait

   1124 int __pthread_cond_timedwait(pthread_cond_t *cond,
   1125                              pthread_mutex_t * mutex,
   1126                              const struct timespec *abstime,
   1127                              clockid_t clock)
   1128 {
   1129     struct timespec ts;
   1130     struct timespec * tsp;
   1131 
   1132     if (abstime != NULL) {
   1133         if (__timespec_to_absolute(&ts, abstime, clock) < 0)
   1134             return ETIMEDOUT;
   1135         tsp = &ts;
   1136     } else {
   1137         tsp = NULL;
   1138     }
   1139 
   1140     return __pthread_cond_timedwait_relative(cond, mutex, tsp); <=====
   1141 }
   1109 int __pthread_cond_timedwait_relative(pthread_cond_t *cond,
   1110                                       pthread_mutex_t * mutex,
   1111                                       const struct timespec *reltime)
   1112 {
   1113     int  status;
   1114     int  oldvalue = cond->value;
   1115 
   1116     pthread_mutex_unlock(mutex);
   1117     status = __futex_wait_ex(&cond->value, COND_IS_SHARED(cond), oldvalue, reltime); <=====
   1118     pthread_mutex_lock(mutex);
   1119 
   1120     if (status == (-ETIMEDOUT)) return ETIMEDOUT;
   1121     return 0;
   1122 }
     49 // __futex_wait(*ftx, val, *timespec)
     50 ENTRY(__futex_wait)
     51     mov     ip, r7
     52     mov     r3, r2
     53     mov     r2, r1
     54     mov     r1, #FUTEX_WAIT
     55     ldr     r7, =__NR_futex
     56     swi     #0
     57     mov     r7, ip
     58     bx      lr
     59 END(__futex_wait)