root / Whitix / branches / hybrid / kernel / wait.c
| Revision 473, 1.8 kB (checked in by mwhitworth, 4 months ago) |
|---|
| Line | |
|---|---|
| 1 | /* This file is part of Whitix. |
| 2 | * |
| 3 | * Whitix is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * Whitix is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with Whitix; if not, write to the Free Software |
| 15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 | * |
| 17 | */ |
| 18 | |
| 19 | #include <module.h> |
| 20 | #include <sched.h> |
| 21 | #include <task.h> |
| 22 | #include <wait.h> |
| 23 | |
| 24 | /*********************************************************************** |
| 25 | * |
| 26 | * FUNCTION: WakeUp |
| 27 | * |
| 28 | * DESCRIPTION: Wake up all threads waiting on a waitqueue. |
| 29 | * |
| 30 | * PARAMETERS: waitQueue - wait queue in question. |
| 31 | * |
| 32 | * RETURNS: Nothing. |
| 33 | * |
| 34 | ***********************************************************************/ |
| 35 | |
| 36 | void WakeUp(WaitQueue* waitQueue) |
| 37 | { |
| 38 | struct WaitQueueEntry* curr, *curr2; |
| 39 | |
| 40 | /* No point if it's empty */ |
| 41 | if (ListEmpty(&waitQueue->list)) |
| 42 | return; |
| 43 | |
| 44 | SpinLockIrq(&waitQueue->spinLock); |
| 45 | |
| 46 | ListForEachEntrySafe(curr, curr2, &(waitQueue->list),next) |
| 47 | { |
| 48 | #ifdef WAIT_DEBUG |
| 49 | if (curr->magic != 0xDEADBEEF) |
| 50 | printf("WakeUp: Error, %#X!, thread = %#X, prev = %#X, next = %#X, magic = %#X, from %#X\n", |
| 51 | waitQueue,curr->thread,curr->next.prev,curr->next.next,curr->magic,__builtin_return_address(0)); |
| 52 | #endif |
| 53 | |
| 54 | ThrResumeThread(curr->thread); |
| 55 | ListRemoveInit(&curr->next); |
| 56 | } |
| 57 | |
| 58 | ListRemoveInit(&waitQueue->list); |
| 59 | SpinUnlockIrq(&waitQueue->spinLock); |
| 60 | } |
| 61 | |
| 62 | SYMBOL_EXPORT(WakeUp); |
Note: See TracBrowser
for help on using the browser.
