| 1 | /**************************************************************************** |
|---|
| 2 | * Copyright (C) 2004, 2005, 2006 v2lin Team <http://v2lin.sf.net> |
|---|
| 3 | * Copyright (C) 2000 Monta Vista Software Inc. |
|---|
| 4 | * |
|---|
| 5 | * This file is part of the v2lin Library. |
|---|
| 6 | * VxWorks is a registered trademark of Wind River Systems, Inc. |
|---|
| 7 | * |
|---|
| 8 | * Initial implementation Gary S. Robertson, 2000, 2001. |
|---|
| 9 | * Contributed by Andrew Skiba, skibochka@sourceforge.net, 2004. |
|---|
| 10 | * Contributed by Mike Kemelmakher, mike@ubxess.com, 2005. |
|---|
| 11 | * Contributed by Constantine Shulyupin, conan.sh@gmail.com, 2006. |
|---|
| 12 | * |
|---|
| 13 | * The v2lin library is free software; you can redistribute it and/or |
|---|
| 14 | * modify it under the terms of the GNU Lesser General Public |
|---|
| 15 | * License as published by the Free Software Foundation; either |
|---|
| 16 | * version 2.1 of the License, or (at your option) any later version. |
|---|
| 17 | * |
|---|
| 18 | * The v2lin Library is distributed in the hope that it will be useful, |
|---|
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 21 | * Lesser General Public License for more details. |
|---|
| 22 | * |
|---|
| 23 | ****************************************************************************/ |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | #ifndef v2l_internal_h |
|---|
| 27 | #define v2l_internal_h |
|---|
| 28 | |
|---|
| 29 | #include "v2lpthread.h" |
|---|
| 30 | #include "vxw_defs.h" |
|---|
| 31 | #include "vxw_hdrs.h" |
|---|
| 32 | #include "v2ldebug.h" |
|---|
| 33 | #include "os_prive.h" |
|---|
| 34 | |
|---|
| 35 | typedef struct v2pt_wdog |
|---|
| 36 | { |
|---|
| 37 | pthread_mutex_t wdog_lock; |
|---|
| 38 | int ticks_remaining; // Ticks remaining until timeout (zero if watchdog already expired). |
|---|
| 39 | void (*timeout_func) (int); |
|---|
| 40 | int timeout_parm; |
|---|
| 41 | struct v2pt_wdog *next; |
|---|
| 42 | } v2pt_wdog_t; |
|---|
| 43 | |
|---|
| 44 | typedef struct v2lsem |
|---|
| 45 | { |
|---|
| 46 | // Mutex and Condition variable for semaphore post/pend |
|---|
| 47 | pthread_mutex_t sem_lock; |
|---|
| 48 | pthread_cond_t sem_send; |
|---|
| 49 | int flags; |
|---|
| 50 | |
|---|
| 51 | //Mutex and Condition variable for semaphore delete |
|---|
| 52 | pthread_mutex_t smdel_lock; |
|---|
| 53 | pthread_cond_t smdel_cplt; |
|---|
| 54 | |
|---|
| 55 | // Count of available 'tokens' for semaphore. |
|---|
| 56 | int token_count; |
|---|
| 57 | |
|---|
| 58 | // Type of send operation last performed on semaphore |
|---|
| 59 | int send_type; |
|---|
| 60 | |
|---|
| 61 | // Ownership nesting level for mutual exclusion semaphore. |
|---|
| 62 | int recursion_level; |
|---|
| 63 | |
|---|
| 64 | // Task control block ptr for task which currently owns semaphore |
|---|
| 65 | unsigned int current_owner; |
|---|
| 66 | |
|---|
| 67 | struct v2lsem *nxt_sem; |
|---|
| 68 | |
|---|
| 69 | // First task control block in list of tasks waiting on semaphore |
|---|
| 70 | DS_TASK_T *first_susp; |
|---|
| 71 | } v2lsem_t; |
|---|
| 72 | |
|---|
| 73 | /* |
|---|
| 74 | ** round_robin_enabled is a system-wide mode flag indicating whether the |
|---|
| 75 | ** v2pthread scheduler is to use FIFO or Round Robin |
|---|
| 76 | ** scheduling. |
|---|
| 77 | */ |
|---|
| 78 | |
|---|
| 79 | #define pthread_mutex_clean_lock(m) \ |
|---|
| 80 | pthread_cleanup_push((void (*)(void *)) pthread_mutex_unlock, m); \ |
|---|
| 81 | pthread_mutex_lock(m); |
|---|
| 82 | |
|---|
| 83 | void status_show(); |
|---|
| 84 | #endif |
|---|