| 272 | } |
| 273 | |
| 274 | struct futex* allocFutex(KThread* thread, U64 address, U32 millies) { |
| 275 | int i=0; |
| 276 | |
| 277 | for (i=0;i<MAX_FUTEXES;i++) { |
| 278 | if (system_futex[i].thread== nullptr) { |
| 279 | BOXEDWINE_CRITICAL_SECTION_WITH_CONDITION(system_futex[i].cond); |
| 280 | if (system_futex[i].thread != nullptr) { |
| 281 | continue; |
| 282 | } |
| 283 | system_futex[i].thread = thread; |
| 284 | system_futex[i].address = address; |
| 285 | system_futex[i].expireTimeInMillies = millies; |
| 286 | system_futex[i].wake = false; |
| 287 | system_futex[i].mask = 0; |
| 288 | system_futex[i].waiting = false; |
| 289 | return &system_futex[i]; |
| 290 | } |
| 291 | } |
| 292 | kpanic("ran out of futexes"); |
| 293 | return nullptr; |
| 294 | } |
| 295 | |
| 296 | void freeFutex(struct futex* f) { |
| 297 | f->thread = nullptr; |