[f3afd24] | 1 | /*
|
---|
| 2 | * Copyright (c) 2009 Jakub Jermar
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup libc
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[1e4cada] | 35 | #include <fibril_synch.h>
|
---|
[f3afd24] | 36 | #include <fibril.h>
|
---|
| 37 | #include <async.h>
|
---|
| 38 | #include <adt/list.h>
|
---|
| 39 | #include <futex.h>
|
---|
[cadfa8e] | 40 | #include <sys/time.h>
|
---|
| 41 | #include <errno.h>
|
---|
[f3afd24] | 42 | #include <assert.h>
|
---|
[1fa010c] | 43 | #include <stacktrace.h>
|
---|
| 44 | #include <stdlib.h>
|
---|
[d161715] | 45 | #include <stdio.h>
|
---|
[e26a4633] | 46 | #include "private/async.h"
|
---|
[f3afd24] | 47 |
|
---|
[8619f25] | 48 | static void optimize_execution_power(void)
|
---|
| 49 | {
|
---|
| 50 | /*
|
---|
| 51 | * When waking up a worker fibril previously blocked in fibril
|
---|
| 52 | * synchronization, chances are that there is an idle manager fibril
|
---|
| 53 | * waiting for IPC, that could start executing the awakened worker
|
---|
| 54 | * fibril right away. We try to detect this and bring the manager
|
---|
| 55 | * fibril back to fruitful work.
|
---|
| 56 | */
|
---|
| 57 | if (atomic_get(&threads_in_ipc_wait) > 0)
|
---|
[64d2b10] | 58 | async_poke();
|
---|
[8619f25] | 59 | }
|
---|
| 60 |
|
---|
[1fa010c] | 61 | static void print_deadlock(fibril_owner_info_t *oi)
|
---|
| 62 | {
|
---|
| 63 | fibril_t *f = (fibril_t *) fibril_get_id();
|
---|
| 64 |
|
---|
[12c38f5] | 65 | printf("Deadlock detected.\n");
|
---|
| 66 | stacktrace_print();
|
---|
[1fa010c] | 67 |
|
---|
| 68 | printf("Fibril %p waits for primitive %p.\n", f, oi);
|
---|
| 69 |
|
---|
| 70 | while (oi && oi->owned_by) {
|
---|
| 71 | printf("Primitive %p is owned by fibril %p.\n",
|
---|
| 72 | oi, oi->owned_by);
|
---|
| 73 | if (oi->owned_by == f)
|
---|
| 74 | break;
|
---|
[84b7384] | 75 | stacktrace_print_fp_pc(context_get_fp(&oi->owned_by->ctx),
|
---|
[12c38f5] | 76 | oi->owned_by->ctx.pc);
|
---|
[1fa010c] | 77 | printf("Fibril %p waits for primitive %p.\n",
|
---|
| 78 | oi->owned_by, oi->owned_by->waits_for);
|
---|
| 79 | oi = oi->owned_by->waits_for;
|
---|
| 80 | }
|
---|
[55bd76c] | 81 | }
|
---|
[1fa010c] | 82 |
|
---|
[55bd76c] | 83 |
|
---|
| 84 | static void check_for_deadlock(fibril_owner_info_t *oi)
|
---|
| 85 | {
|
---|
| 86 | while (oi && oi->owned_by) {
|
---|
| 87 | if (oi->owned_by == (fibril_t *) fibril_get_id()) {
|
---|
| 88 | print_deadlock(oi);
|
---|
| 89 | abort();
|
---|
| 90 | }
|
---|
| 91 | oi = oi->owned_by->waits_for;
|
---|
| 92 | }
|
---|
[1fa010c] | 93 | }
|
---|
| 94 |
|
---|
[55bd76c] | 95 |
|
---|
[f3afd24] | 96 | void fibril_mutex_initialize(fibril_mutex_t *fm)
|
---|
| 97 | {
|
---|
[3e20fd48] | 98 | fm->oi.owned_by = NULL;
|
---|
[f3afd24] | 99 | fm->counter = 1;
|
---|
| 100 | list_initialize(&fm->waiters);
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | void fibril_mutex_lock(fibril_mutex_t *fm)
|
---|
| 104 | {
|
---|
[525df28] | 105 | fibril_t *f = (fibril_t *) fibril_get_id();
|
---|
| 106 |
|
---|
[0c70f7e] | 107 | if (fibril_get_sercount() != 0)
|
---|
[47b7006] | 108 | abort();
|
---|
[0c70f7e] | 109 |
|
---|
[f3afd24] | 110 | futex_down(&async_futex);
|
---|
| 111 | if (fm->counter-- <= 0) {
|
---|
[854ad23] | 112 | awaiter_t wdata;
|
---|
| 113 |
|
---|
| 114 | wdata.fid = fibril_get_id();
|
---|
| 115 | wdata.active = false;
|
---|
| 116 | wdata.wu_event.inlist = true;
|
---|
| 117 | link_initialize(&wdata.wu_event.link);
|
---|
| 118 | list_append(&wdata.wu_event.link, &fm->waiters);
|
---|
[55bd76c] | 119 | check_for_deadlock(&fm->oi);
|
---|
[525df28] | 120 | f->waits_for = &fm->oi;
|
---|
[f3afd24] | 121 | fibril_switch(FIBRIL_TO_MANAGER);
|
---|
| 122 | } else {
|
---|
[525df28] | 123 | fm->oi.owned_by = f;
|
---|
[f3afd24] | 124 | futex_up(&async_futex);
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | bool fibril_mutex_trylock(fibril_mutex_t *fm)
|
---|
| 129 | {
|
---|
| 130 | bool locked = false;
|
---|
| 131 |
|
---|
| 132 | futex_down(&async_futex);
|
---|
| 133 | if (fm->counter > 0) {
|
---|
| 134 | fm->counter--;
|
---|
[3e20fd48] | 135 | fm->oi.owned_by = (fibril_t *) fibril_get_id();
|
---|
[f3afd24] | 136 | locked = true;
|
---|
| 137 | }
|
---|
| 138 | futex_up(&async_futex);
|
---|
| 139 |
|
---|
| 140 | return locked;
|
---|
| 141 | }
|
---|
| 142 |
|
---|
[9ae22ba] | 143 | static void _fibril_mutex_unlock_unsafe(fibril_mutex_t *fm)
|
---|
[f3afd24] | 144 | {
|
---|
| 145 | if (fm->counter++ < 0) {
|
---|
| 146 | link_t *tmp;
|
---|
[854ad23] | 147 | awaiter_t *wdp;
|
---|
[525df28] | 148 | fibril_t *f;
|
---|
[f3afd24] | 149 |
|
---|
| 150 | assert(!list_empty(&fm->waiters));
|
---|
| 151 | tmp = fm->waiters.next;
|
---|
[854ad23] | 152 | wdp = list_get_instance(tmp, awaiter_t, wu_event.link);
|
---|
[bbb01b98] | 153 | wdp->active = true;
|
---|
[854ad23] | 154 | wdp->wu_event.inlist = false;
|
---|
[525df28] | 155 |
|
---|
| 156 | f = (fibril_t *) wdp->fid;
|
---|
| 157 | fm->oi.owned_by = f;
|
---|
| 158 | f->waits_for = NULL;
|
---|
| 159 |
|
---|
[854ad23] | 160 | list_remove(&wdp->wu_event.link);
|
---|
| 161 | fibril_add_ready(wdp->fid);
|
---|
[8619f25] | 162 | optimize_execution_power();
|
---|
[3e20fd48] | 163 | } else {
|
---|
| 164 | fm->oi.owned_by = NULL;
|
---|
[f3afd24] | 165 | }
|
---|
[9ae22ba] | 166 | }
|
---|
| 167 |
|
---|
| 168 | void fibril_mutex_unlock(fibril_mutex_t *fm)
|
---|
| 169 | {
|
---|
[b0a76d5] | 170 | assert(fibril_mutex_is_locked(fm));
|
---|
[9ae22ba] | 171 | futex_down(&async_futex);
|
---|
| 172 | _fibril_mutex_unlock_unsafe(fm);
|
---|
[f3afd24] | 173 | futex_up(&async_futex);
|
---|
| 174 | }
|
---|
| 175 |
|
---|
[b0a76d5] | 176 | bool fibril_mutex_is_locked(fibril_mutex_t *fm)
|
---|
| 177 | {
|
---|
| 178 | bool locked = false;
|
---|
| 179 |
|
---|
| 180 | futex_down(&async_futex);
|
---|
| 181 | if (fm->counter <= 0)
|
---|
| 182 | locked = true;
|
---|
| 183 | futex_up(&async_futex);
|
---|
| 184 |
|
---|
| 185 | return locked;
|
---|
| 186 | }
|
---|
| 187 |
|
---|
[f3afd24] | 188 | void fibril_rwlock_initialize(fibril_rwlock_t *frw)
|
---|
| 189 | {
|
---|
[3e20fd48] | 190 | frw->oi.owned_by = NULL;
|
---|
[92d34f0b] | 191 | frw->writers = 0;
|
---|
| 192 | frw->readers = 0;
|
---|
| 193 | list_initialize(&frw->waiters);
|
---|
[f3afd24] | 194 | }
|
---|
| 195 |
|
---|
| 196 | void fibril_rwlock_read_lock(fibril_rwlock_t *frw)
|
---|
| 197 | {
|
---|
[9414abc] | 198 | fibril_t *f = (fibril_t *) fibril_get_id();
|
---|
| 199 |
|
---|
[0c70f7e] | 200 | if (fibril_get_sercount() != 0)
|
---|
[47b7006] | 201 | abort();
|
---|
[0c70f7e] | 202 |
|
---|
[92d34f0b] | 203 | futex_down(&async_futex);
|
---|
| 204 | if (frw->writers) {
|
---|
[b69bec5] | 205 | awaiter_t wdata;
|
---|
| 206 |
|
---|
| 207 | wdata.fid = (fid_t) f;
|
---|
| 208 | wdata.active = false;
|
---|
| 209 | wdata.wu_event.inlist = true;
|
---|
| 210 | link_initialize(&wdata.wu_event.link);
|
---|
[92d34f0b] | 211 | f->flags &= ~FIBRIL_WRITER;
|
---|
[b69bec5] | 212 | list_append(&wdata.wu_event.link, &frw->waiters);
|
---|
[55bd76c] | 213 | check_for_deadlock(&frw->oi);
|
---|
[649efcd] | 214 | f->waits_for = &frw->oi;
|
---|
[92d34f0b] | 215 | fibril_switch(FIBRIL_TO_MANAGER);
|
---|
| 216 | } else {
|
---|
[9414abc] | 217 | /* Consider the first reader the owner. */
|
---|
| 218 | if (frw->readers++ == 0)
|
---|
| 219 | frw->oi.owned_by = f;
|
---|
[92d34f0b] | 220 | futex_up(&async_futex);
|
---|
| 221 | }
|
---|
[f3afd24] | 222 | }
|
---|
| 223 |
|
---|
| 224 | void fibril_rwlock_write_lock(fibril_rwlock_t *frw)
|
---|
| 225 | {
|
---|
[649efcd] | 226 | fibril_t *f = (fibril_t *) fibril_get_id();
|
---|
| 227 |
|
---|
[0c70f7e] | 228 | if (fibril_get_sercount() != 0)
|
---|
[47b7006] | 229 | abort();
|
---|
[0c70f7e] | 230 |
|
---|
[92d34f0b] | 231 | futex_down(&async_futex);
|
---|
| 232 | if (frw->writers || frw->readers) {
|
---|
[b69bec5] | 233 | awaiter_t wdata;
|
---|
| 234 |
|
---|
| 235 | wdata.fid = (fid_t) f;
|
---|
| 236 | wdata.active = false;
|
---|
| 237 | wdata.wu_event.inlist = true;
|
---|
| 238 | link_initialize(&wdata.wu_event.link);
|
---|
[92d34f0b] | 239 | f->flags |= FIBRIL_WRITER;
|
---|
[b69bec5] | 240 | list_append(&wdata.wu_event.link, &frw->waiters);
|
---|
[55bd76c] | 241 | check_for_deadlock(&frw->oi);
|
---|
[649efcd] | 242 | f->waits_for = &frw->oi;
|
---|
[92d34f0b] | 243 | fibril_switch(FIBRIL_TO_MANAGER);
|
---|
| 244 | } else {
|
---|
[649efcd] | 245 | frw->oi.owned_by = f;
|
---|
[92d34f0b] | 246 | frw->writers++;
|
---|
| 247 | futex_up(&async_futex);
|
---|
| 248 | }
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 | static void _fibril_rwlock_common_unlock(fibril_rwlock_t *frw)
|
---|
| 252 | {
|
---|
| 253 | futex_down(&async_futex);
|
---|
| 254 | if (frw->readers) {
|
---|
[9414abc] | 255 | if (--frw->readers) {
|
---|
| 256 | if (frw->oi.owned_by == (fibril_t *) fibril_get_id()) {
|
---|
| 257 | /*
|
---|
| 258 | * If this reader firbril was considered the
|
---|
| 259 | * owner of this rwlock, clear the ownership
|
---|
| 260 | * information even if there are still more
|
---|
| 261 | * readers.
|
---|
| 262 | *
|
---|
| 263 | * This is the limitation of the detection
|
---|
| 264 | * mechanism rooted in the fact that tracking
|
---|
| 265 | * all readers would require dynamically
|
---|
| 266 | * allocated memory for keeping linkage info.
|
---|
| 267 | */
|
---|
| 268 | frw->oi.owned_by = NULL;
|
---|
| 269 | }
|
---|
[92d34f0b] | 270 | goto out;
|
---|
[9414abc] | 271 | }
|
---|
[92d34f0b] | 272 | } else {
|
---|
| 273 | frw->writers--;
|
---|
| 274 | }
|
---|
| 275 |
|
---|
| 276 | assert(!frw->readers && !frw->writers);
|
---|
| 277 |
|
---|
[649efcd] | 278 | frw->oi.owned_by = NULL;
|
---|
| 279 |
|
---|
[92d34f0b] | 280 | while (!list_empty(&frw->waiters)) {
|
---|
| 281 | link_t *tmp = frw->waiters.next;
|
---|
[b69bec5] | 282 | awaiter_t *wdp;
|
---|
| 283 | fibril_t *f;
|
---|
| 284 |
|
---|
| 285 | wdp = list_get_instance(tmp, awaiter_t, wu_event.link);
|
---|
| 286 | f = (fibril_t *) wdp->fid;
|
---|
[92d34f0b] | 287 |
|
---|
[649efcd] | 288 | f->waits_for = NULL;
|
---|
| 289 |
|
---|
[92d34f0b] | 290 | if (f->flags & FIBRIL_WRITER) {
|
---|
| 291 | if (frw->readers)
|
---|
| 292 | break;
|
---|
[b69bec5] | 293 | wdp->active = true;
|
---|
| 294 | wdp->wu_event.inlist = false;
|
---|
| 295 | list_remove(&wdp->wu_event.link);
|
---|
| 296 | fibril_add_ready(wdp->fid);
|
---|
[92d34f0b] | 297 | frw->writers++;
|
---|
[649efcd] | 298 | frw->oi.owned_by = f;
|
---|
[8619f25] | 299 | optimize_execution_power();
|
---|
[92d34f0b] | 300 | break;
|
---|
| 301 | } else {
|
---|
[b69bec5] | 302 | wdp->active = true;
|
---|
| 303 | wdp->wu_event.inlist = false;
|
---|
| 304 | list_remove(&wdp->wu_event.link);
|
---|
| 305 | fibril_add_ready(wdp->fid);
|
---|
[9414abc] | 306 | if (frw->readers++ == 0) {
|
---|
| 307 | /* Consider the first reader the owner. */
|
---|
| 308 | frw->oi.owned_by = f;
|
---|
| 309 | }
|
---|
[8619f25] | 310 | optimize_execution_power();
|
---|
[92d34f0b] | 311 | }
|
---|
| 312 | }
|
---|
| 313 | out:
|
---|
| 314 | futex_up(&async_futex);
|
---|
[f3afd24] | 315 | }
|
---|
| 316 |
|
---|
| 317 | void fibril_rwlock_read_unlock(fibril_rwlock_t *frw)
|
---|
| 318 | {
|
---|
[b0a76d5] | 319 | assert(fibril_rwlock_is_read_locked(frw));
|
---|
[92d34f0b] | 320 | _fibril_rwlock_common_unlock(frw);
|
---|
[f3afd24] | 321 | }
|
---|
| 322 |
|
---|
| 323 | void fibril_rwlock_write_unlock(fibril_rwlock_t *frw)
|
---|
| 324 | {
|
---|
[b0a76d5] | 325 | assert(fibril_rwlock_is_write_locked(frw));
|
---|
[92d34f0b] | 326 | _fibril_rwlock_common_unlock(frw);
|
---|
[f3afd24] | 327 | }
|
---|
| 328 |
|
---|
[b0a76d5] | 329 | bool fibril_rwlock_is_read_locked(fibril_rwlock_t *frw)
|
---|
| 330 | {
|
---|
| 331 | bool locked = false;
|
---|
| 332 |
|
---|
| 333 | futex_down(&async_futex);
|
---|
| 334 | if (frw->readers)
|
---|
| 335 | locked = true;
|
---|
| 336 | futex_up(&async_futex);
|
---|
| 337 |
|
---|
| 338 | return locked;
|
---|
| 339 | }
|
---|
| 340 |
|
---|
| 341 | bool fibril_rwlock_is_write_locked(fibril_rwlock_t *frw)
|
---|
| 342 | {
|
---|
| 343 | bool locked = false;
|
---|
| 344 |
|
---|
| 345 | futex_down(&async_futex);
|
---|
| 346 | if (frw->writers) {
|
---|
| 347 | assert(frw->writers == 1);
|
---|
| 348 | locked = true;
|
---|
| 349 | }
|
---|
| 350 | futex_up(&async_futex);
|
---|
| 351 |
|
---|
| 352 | return locked;
|
---|
| 353 | }
|
---|
| 354 |
|
---|
[c81b6f2] | 355 | bool fibril_rwlock_is_locked(fibril_rwlock_t *frw)
|
---|
| 356 | {
|
---|
| 357 | return fibril_rwlock_is_read_locked(frw) ||
|
---|
| 358 | fibril_rwlock_is_write_locked(frw);
|
---|
| 359 | }
|
---|
| 360 |
|
---|
[9ae22ba] | 361 | void fibril_condvar_initialize(fibril_condvar_t *fcv)
|
---|
| 362 | {
|
---|
| 363 | list_initialize(&fcv->waiters);
|
---|
| 364 | }
|
---|
| 365 |
|
---|
[cadfa8e] | 366 | int
|
---|
| 367 | fibril_condvar_wait_timeout(fibril_condvar_t *fcv, fibril_mutex_t *fm,
|
---|
| 368 | suseconds_t timeout)
|
---|
[9ae22ba] | 369 | {
|
---|
[cadfa8e] | 370 | awaiter_t wdata;
|
---|
| 371 |
|
---|
[b0a76d5] | 372 | assert(fibril_mutex_is_locked(fm));
|
---|
| 373 |
|
---|
[cadfa8e] | 374 | if (timeout < 0)
|
---|
| 375 | return ETIMEOUT;
|
---|
| 376 |
|
---|
| 377 | wdata.fid = fibril_get_id();
|
---|
| 378 | wdata.active = false;
|
---|
| 379 |
|
---|
| 380 | wdata.to_event.inlist = timeout > 0;
|
---|
| 381 | wdata.to_event.occurred = false;
|
---|
| 382 | link_initialize(&wdata.to_event.link);
|
---|
| 383 |
|
---|
| 384 | wdata.wu_event.inlist = true;
|
---|
| 385 | link_initialize(&wdata.wu_event.link);
|
---|
[9ae22ba] | 386 |
|
---|
| 387 | futex_down(&async_futex);
|
---|
[cadfa8e] | 388 | if (timeout) {
|
---|
| 389 | gettimeofday(&wdata.to_event.expires, NULL);
|
---|
| 390 | tv_add(&wdata.to_event.expires, timeout);
|
---|
| 391 | async_insert_timeout(&wdata);
|
---|
| 392 | }
|
---|
| 393 | list_append(&wdata.wu_event.link, &fcv->waiters);
|
---|
[9ae22ba] | 394 | _fibril_mutex_unlock_unsafe(fm);
|
---|
| 395 | fibril_switch(FIBRIL_TO_MANAGER);
|
---|
| 396 | fibril_mutex_lock(fm);
|
---|
[cadfa8e] | 397 |
|
---|
| 398 | /* async_futex not held after fibril_switch() */
|
---|
| 399 | futex_down(&async_futex);
|
---|
| 400 | if (wdata.to_event.inlist)
|
---|
| 401 | list_remove(&wdata.to_event.link);
|
---|
| 402 | if (wdata.wu_event.inlist)
|
---|
| 403 | list_remove(&wdata.wu_event.link);
|
---|
| 404 | futex_up(&async_futex);
|
---|
| 405 |
|
---|
| 406 | return wdata.to_event.occurred ? ETIMEOUT : EOK;
|
---|
| 407 | }
|
---|
| 408 |
|
---|
| 409 | void fibril_condvar_wait(fibril_condvar_t *fcv, fibril_mutex_t *fm)
|
---|
| 410 | {
|
---|
| 411 | int rc;
|
---|
| 412 |
|
---|
| 413 | rc = fibril_condvar_wait_timeout(fcv, fm, 0);
|
---|
| 414 | assert(rc == EOK);
|
---|
[9ae22ba] | 415 | }
|
---|
| 416 |
|
---|
| 417 | static void _fibril_condvar_wakeup_common(fibril_condvar_t *fcv, bool once)
|
---|
| 418 | {
|
---|
| 419 | link_t *tmp;
|
---|
[cadfa8e] | 420 | awaiter_t *wdp;
|
---|
[9ae22ba] | 421 |
|
---|
| 422 | futex_down(&async_futex);
|
---|
| 423 | while (!list_empty(&fcv->waiters)) {
|
---|
| 424 | tmp = fcv->waiters.next;
|
---|
[cadfa8e] | 425 | wdp = list_get_instance(tmp, awaiter_t, wu_event.link);
|
---|
| 426 | list_remove(&wdp->wu_event.link);
|
---|
| 427 | wdp->wu_event.inlist = false;
|
---|
| 428 | if (!wdp->active) {
|
---|
| 429 | wdp->active = true;
|
---|
| 430 | fibril_add_ready(wdp->fid);
|
---|
| 431 | optimize_execution_power();
|
---|
| 432 | if (once)
|
---|
| 433 | break;
|
---|
| 434 | }
|
---|
[9ae22ba] | 435 | }
|
---|
| 436 | futex_up(&async_futex);
|
---|
| 437 | }
|
---|
| 438 |
|
---|
| 439 | void fibril_condvar_signal(fibril_condvar_t *fcv)
|
---|
| 440 | {
|
---|
| 441 | _fibril_condvar_wakeup_common(fcv, true);
|
---|
| 442 | }
|
---|
| 443 |
|
---|
| 444 | void fibril_condvar_broadcast(fibril_condvar_t *fcv)
|
---|
| 445 | {
|
---|
| 446 | _fibril_condvar_wakeup_common(fcv, false);
|
---|
| 447 | }
|
---|
| 448 |
|
---|
[f3afd24] | 449 | /** @}
|
---|
| 450 | */
|
---|