Changeset d25b2d6
- Timestamp:
- Dec 16, 2020, 3:43:34 PM (2 years ago)
- Branches:
- ADT, arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 8a81b09
- Parents:
- c131a02
- Location:
- libcfa/src/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
rc131a02 rd25b2d6 18 18 #include "bits/locks.hfa" 19 19 #include "kernel/fwd.hfa" 20 #include <stddef.h>21 20 22 21 #ifdef __cforall -
libcfa/src/concurrency/locks.cfa
rc131a02 rd25b2d6 364 364 } 365 365 } 366 367 // const unsigned int num_times = 50000;368 369 // multiple_acquisition_lock m;370 // condition_variable( multiple_acquisition_lock ) c_m;371 372 // single_acquisition_lock s;373 // condition_variable( single_acquisition_lock ) c_s;374 375 // owner_lock o;376 // condition_variable( owner_lock ) c_o;377 378 // thread T_C_M_WS1 {};379 380 // void main( T_C_M_WS1 & this ) {381 // fprintf(stderr, "start of thd main listed: %d\n", listed(active_thread()) );382 // fprintf(stderr, "thread colable next ptr in start of thd main %p\n", Next( (Colable *)active_thread() ) );383 // for (unsigned int i = 0; i < num_times; i++) {384 // lock(m);385 // if(empty(c_m) && i != num_times - 1) {386 // wait(c_m,m);387 // }else{388 // notify_one(c_m);389 // }390 // unlock(m);391 // }392 // }393 394 // thread T_C_M_WB1 {};395 396 // void main( T_C_M_WB1 & this ) {397 // for (unsigned int i = 0; i < num_times; i++) {398 // lock(m);399 // if(counter(c_m) == 3 || i == num_times - 1) {400 // notify_all(c_m);401 // }else{402 // wait(c_m,m);403 // }404 // unlock(m);405 // }406 // }407 408 // thread T_C_S_WS1 {};409 410 // void main( T_C_S_WS1 & this ) {411 // for (unsigned int i = 0; i < num_times; i++) {412 // lock(s);413 // if(empty(c_s) && i != num_times - 1) {414 // wait(c_s,s);415 // }else{416 // notify_one(c_s);417 // }418 // unlock(s);419 // }420 // }421 422 // thread T_C_S_WB1 {};423 424 // void main( T_C_S_WB1 & this ) {425 // for (unsigned int i = 0; i < num_times; i++) {426 // lock(s);427 // if(counter(c_s) == 3 || i == num_times - 1) {428 // notify_all(c_s);429 // }else{430 // wait(c_s,s);431 // }432 // unlock(s);433 // }434 // }435 436 // thread T_C_O_WS1 {};437 438 // void main( T_C_O_WS1 & this ) {439 // for (unsigned int i = 0; i < num_times; i++) {440 // lock(o);441 // if(empty(c_o) && i != num_times - 1) {442 // wait(c_o,o);443 // }else{444 // notify_one(c_o);445 // }446 // unlock(o);447 // }448 // }449 450 // thread T_C_O_WB1 {};451 452 // void main( T_C_O_WB1 & this ) {453 // for (unsigned int i = 0; i < num_times; i++) {454 // lock(o);455 // if(counter(c_o) == 3 || i == num_times - 1) {456 // notify_all(c_o);457 // }else{458 // wait(c_o,o);459 // }460 // unlock(o);461 // }462 // }463 464 // thread T_C_M_WS2 {};465 466 // void main( T_C_M_WS2 & this ) {467 // for (unsigned int i = 0; i < num_times; i++) {468 // lock(m);469 // lock(m);470 // lock(m);471 // if(empty(c_m) && i != num_times - 1) {472 // wait(c_m,m);473 // }else{474 // notify_one(c_m);475 // }476 // unlock(m);477 // unlock(m);478 // unlock(m);479 // }480 // }481 482 // thread T_C_O_WS2 {};483 484 // void main( T_C_O_WS2 & this ) {485 // for (unsigned int i = 0; i < num_times; i++) {486 // lock(o);487 // lock(o);488 // lock(o);489 // if(empty(c_o) && i != num_times - 1) {490 // wait(c_o,o);491 // }else{492 // notify_one(c_o);493 // }494 // unlock(o);495 // unlock(o);496 // unlock(o);497 // }498 // }499 500 // thread T_C_NLW {};501 502 // void main( T_C_NLW & this ) {503 // for (unsigned int i = 0; i < num_times; i++) {504 // wait(c_o);505 // }506 // }507 508 // thread T_C_NLS {};509 510 // void main( T_C_NLS & this ) {511 // for (unsigned int i = 0; i < num_times; i++) {512 // while (empty(c_o)) { }513 // notify_one(c_o);514 // }515 // }516 517 // thread T_C_S_WNF {};518 519 // void main( T_C_S_WNF & this ) {520 // for (unsigned int i = 0; i < num_times; i++) {521 // lock(s);522 // if(empty(c_s) && i != num_times - 1) {523 // wait(c_s, s, 10);524 // }else{525 // if(!empty(c_s)) assert(front(c_s) == 10);526 // notify_one(c_s);527 // }528 // unlock(s);529 // }530 // }531 532 // bool done = false;533 534 // thread T_C_NLWD {};535 536 // void main( T_C_NLWD & this ) {537 // done = false;538 // for (unsigned int i = 0; i < num_times; i++) {539 // wait(c_s, 1`ns);540 // }541 // done = true;542 // }543 544 // thread T_C_WDS {};545 546 // void main( T_C_WDS & this ) {547 // for (unsigned int i = 0; i < num_times; i++) {548 // while (empty(c_s) && !done) { }549 // notify_one(c_s);550 // sleep(1`ns);551 // if(done) break;552 // }553 // }554 555 // thread T_C_LWD {};556 557 // void main( T_C_LWD & this ) {558 // done = false;559 // for (unsigned int i = 0; i < num_times; i++) {560 // if (i % 500 == 0) printf("!! %d\n", i);561 // lock(s);562 // wait(c_s, s, 1`ns);563 // unlock(s);564 // }565 // done = true;566 // }567 568 // int main() {569 // processor p[2];570 // printf("Start Test 1: multi acquisition lock and condition variable single wait/notify\n");571 // {572 // T_C_M_WS1 t1;573 // }574 // printf("Done Test 1\n");575 576 // printf("Start Test 2: multi acquisition lock and condition variable 3 wait/notify all\n");577 // {578 // T_C_M_WB1 t1[4];579 // }580 // printf("Done Test 2\n");581 582 // printf("Start Test 3: single acquisition lock and condition variable single wait/notify\n");583 // {584 // T_C_S_WS1 t1[2];585 // }586 // printf("Done Test 3\n");587 588 // printf("Start Test 4: single acquisition lock and condition variable 3 wait/notify all\n");589 // {590 // T_C_S_WB1 t1[4];591 // }592 // printf("Done Test 4\n");593 594 // printf("Start Test 5: owner lock and condition variable single wait/notify\n");595 // {596 // T_C_O_WS1 t1[2];597 // }598 // printf("Done Test 5\n");599 600 // printf("Start Test 6: owner lock and condition variable 3 wait/notify all\n");601 // {602 // T_C_O_WB1 t1[4];603 // }604 // printf("Done Test 6\n");605 606 // printf("Start Test 7: multi acquisiton lock and condition variable multiple acquire and wait/notify\n");607 // {608 // T_C_M_WS2 t1[2];609 // }610 // printf("Done Test 7\n");611 612 // printf("Start Test 8: owner lock and condition variable multiple acquire and wait/notify\n");613 // {614 // T_C_O_WS2 t1[2];615 // }616 // printf("Done Test 8\n");617 618 // printf("Start Test 9: no lock condition variable wait/notify\n");619 // {620 // T_C_NLW t1;621 // T_C_NLS t2;622 // }623 // printf("Done Test 9\n");624 625 // printf("Start Test 10: locked condition variable wait/notify with front()\n");626 // {627 // T_C_S_WNF t1[2];628 // }629 // printf("Done Test 10\n");630 631 // printf("Start Test 11: unlocked condition variable delay wait\n");632 // {633 // T_C_NLWD t1;634 // T_C_WDS t2;635 // }636 // printf("Done Test 11\n");637 638 // // printf("Start Test 12: locked condition variable delay wait\n");639 // // {640 // // T_C_LWD t1;641 // // T_C_WDS t2;642 // // }643 // // printf("Done Test 12\n");644 // }
Note: See TracChangeset
for help on using the changeset viewer.