Mercurial > flash_v2
comparison packages/kernel/current/src/sync/mutex.cxx @ 124:0ec04793409a ecos-sw-2000-09-11
Merge from eCos master repository on 2000-09-11-03:00:13-BST
| author | jlarmour |
|---|---|
| date | Mon, 11 Sep 2000 02:42:46 +0000 |
| parents | 6ed91473a1cd |
| children | 4c750ce71ae3 |
comparison
equal
deleted
inserted
replaced
| 123:9b71e8e665a3 | 124:0ec04793409a |
|---|---|
| 555 CYG_REPORT_FUNCTION(); | 555 CYG_REPORT_FUNCTION(); |
| 556 | 556 |
| 557 cyg_bool result = true; | 557 cyg_bool result = true; |
| 558 Cyg_Thread *self = Cyg_Thread::self(); | 558 Cyg_Thread *self = Cyg_Thread::self(); |
| 559 | 559 |
| 560 cyg_int32 current_lock = Cyg_Scheduler::get_sched_lock(); | 560 Cyg_Scheduler::lock(); |
| 561 | |
| 562 if (current_lock == 0) | |
| 563 // Prevent preemption | |
| 564 Cyg_Scheduler::lock(); | |
| 565 | 561 |
| 566 CYG_ASSERTCLASS( this, "Bad this pointer"); | 562 CYG_ASSERTCLASS( this, "Bad this pointer"); |
| 567 CYG_ASSERTCLASS( mx, "Corrupt mutex"); | 563 CYG_ASSERTCLASS( mx, "Corrupt mutex"); |
| 568 CYG_ASSERTCLASS( self, "Bad self thread"); | 564 CYG_ASSERTCLASS( self, "Bad self thread"); |
| 569 | 565 |
| 575 | 571 |
| 576 self->sleep(); | 572 self->sleep(); |
| 577 | 573 |
| 578 queue.enqueue( self ); | 574 queue.enqueue( self ); |
| 579 | 575 |
| 580 CYG_ASSERT( Cyg_Scheduler::get_sched_lock() == 1, "Called with non-zero scheduler lock"); | |
| 581 | |
| 582 // Avoid calling ASRs during the following unlock. | 576 // Avoid calling ASRs during the following unlock. |
| 583 self->set_asr_inhibit(); | 577 self->set_asr_inhibit(); |
| 584 | 578 |
| 585 // Unlock the scheduler and switch threads | 579 // Unlock the scheduler and switch threads |
| 586 Cyg_Scheduler::unlock(); | 580 Cyg_Scheduler::unlock_reschedule(); |
| 587 | 581 |
| 588 // Allow ASRs again | 582 // Allow ASRs again |
| 589 self->clear_asr_inhibit(); | 583 self->clear_asr_inhibit(); |
| 590 | 584 |
| 591 CYG_INSTRUMENT_CONDVAR(WOKE, this, self->get_wake_reason()); | 585 CYG_INSTRUMENT_CONDVAR(WOKE, this, self->get_wake_reason()); |
| 624 CYG_ASSERTCLASS( mx, "Corrupt mutex"); | 618 CYG_ASSERTCLASS( mx, "Corrupt mutex"); |
| 625 CYG_ASSERT( mx->owner == self, "Not mutex owner"); | 619 CYG_ASSERT( mx->owner == self, "Not mutex owner"); |
| 626 | 620 |
| 627 CYG_REPORT_RETURN(); | 621 CYG_REPORT_RETURN(); |
| 628 | 622 |
| 629 if (current_lock) | |
| 630 // Reacquire the DSR pseudo lock | |
| 631 Cyg_Scheduler::lock(); | |
| 632 | |
| 633 return result; | 623 return result; |
| 634 } | 624 } |
| 635 | 625 |
| 636 // ------------------------------------------------------------------------- | 626 // ------------------------------------------------------------------------- |
| 637 // Wake one thread | 627 // Wake one thread |
| 750 | 740 |
| 751 // Only enqueue if the timeout has not already fired. | 741 // Only enqueue if the timeout has not already fired. |
| 752 if( self->get_wake_reason() == Cyg_Thread::NONE ) | 742 if( self->get_wake_reason() == Cyg_Thread::NONE ) |
| 753 queue.enqueue( self ); | 743 queue.enqueue( self ); |
| 754 | 744 |
| 755 CYG_ASSERT( Cyg_Scheduler::get_sched_lock() == 1, "Called with non-zero scheduler lock"); | |
| 756 | |
| 757 // Avoid calling ASRs during the following unlock. | 745 // Avoid calling ASRs during the following unlock. |
| 758 self->set_asr_inhibit(); | 746 self->set_asr_inhibit(); |
| 759 | 747 |
| 760 // Unlock the scheduler and switch threads | 748 // Unlock the scheduler and switch threads |
| 761 Cyg_Scheduler::unlock(); | 749 Cyg_Scheduler::unlock_reschedule(); |
| 762 | 750 |
| 763 // Allow ASRs again | 751 // Allow ASRs again |
| 764 self->clear_asr_inhibit(); | 752 self->clear_asr_inhibit(); |
| 765 | 753 |
| 766 CYG_ASSERTCLASS( this, "Bad this pointer"); | 754 CYG_ASSERTCLASS( this, "Bad this pointer"); |
