| 1 | /**************************************************************************** |
|---|
| 2 | * Copyright (C) 2004, 2005, 2006 v2lin Team <http://v2lin.sf.net> |
|---|
| 3 | * Copyright (C) 2000,2001 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 | #ifndef v2lpthread_h |
|---|
| 26 | #define v2lpthread_h |
|---|
| 27 | #include <pthread.h> |
|---|
| 28 | //#include <asm/atomic.h> |
|---|
| 29 | |
|---|
| 30 | __BEGIN_DECLS; |
|---|
| 31 | |
|---|
| 32 | #ifndef FALSE |
|---|
| 33 | #define FALSE 0 |
|---|
| 34 | #endif |
|---|
| 35 | #ifndef TRUE |
|---|
| 36 | #define TRUE !FALSE |
|---|
| 37 | #endif |
|---|
| 38 | #define V2PT_TICK 10 /* milliseconds per v2pthread scheduler tick */ |
|---|
| 39 | /* |
|---|
| 40 | ** Task Scheduling Priorities in v2pthread are higher as numbers decrease... |
|---|
| 41 | ** define the largest and smallest possible priority numbers. |
|---|
| 42 | */ |
|---|
| 43 | #define MIN_V2PT_PRIORITY 255 |
|---|
| 44 | #define MAX_V2PT_PRIORITY 0 |
|---|
| 45 | #ifndef OK |
|---|
| 46 | #define OK 0 /* Normal return value */ |
|---|
| 47 | #endif |
|---|
| 48 | #ifndef ERROR |
|---|
| 49 | #define ERROR -1 /* Error return value */ |
|---|
| 50 | #endif |
|---|
| 51 | |
|---|
| 52 | #if 0 |
|---|
| 53 | // Task state bit masks |
|---|
| 54 | #define READY 0x0000 |
|---|
| 55 | #define PEND 0x0001 |
|---|
| 56 | #define DELAY 0x0002 |
|---|
| 57 | #define SUSPEND 0x0004 |
|---|
| 58 | #define TIMEOUT 0x0008 |
|---|
| 59 | #define INH_PRI 0x0010 |
|---|
| 60 | #define DEAD 0x0080 |
|---|
| 61 | #define RDY_MSK 0x008f |
|---|
| 62 | // |
|---|
| 63 | // Control block for pthread wrapper for v2pthread task |
|---|
| 64 | typedef struct task_s |
|---|
| 65 | { |
|---|
| 66 | #if 0 |
|---|
| 67 | struct sched_param prv_priority; |
|---|
| 68 | int check; |
|---|
| 69 | int taskid; |
|---|
| 70 | char *taskname; |
|---|
| 71 | pthread_t pthrid; |
|---|
| 72 | pthread_attr_t attr; |
|---|
| 73 | int (*entry_point) (int, int, int, int, int, int, int, int, int, int); |
|---|
| 74 | int parms[10]; |
|---|
| 75 | int static_task; // Flag indicating if task control block allocated dynamically ( == 0 ) |
|---|
| 76 | int flags; |
|---|
| 77 | int vxw_priority; |
|---|
| 78 | // struct task_s *suspend_list; use waiting instead |
|---|
| 79 | int delete_safe_count; // Nesting level for number of taskSafe calls |
|---|
| 80 | // Mutex and Condition variable for task delete 'pend' |
|---|
| 81 | pthread_mutex_t tdelete_lock; |
|---|
| 82 | pthread_cond_t t_deletable; |
|---|
| 83 | |
|---|
| 84 | // Mutex and Condition variable for task delete 'broadcast' |
|---|
| 85 | pthread_mutex_t dbcst_lock; |
|---|
| 86 | pthread_cond_t delete_bcplt; |
|---|
| 87 | |
|---|
| 88 | #endif |
|---|
| 89 | |
|---|
| 90 | int state; |
|---|
| 91 | |
|---|
| 92 | // First task control block in list of tasks waiting on this task (for deletion purposes) |
|---|
| 93 | struct task_s *first_susp; |
|---|
| 94 | struct task_s *nxt_susp; // Next task control block in list of tasks waiting on object |
|---|
| 95 | |
|---|
| 96 | // Next task control block in list |
|---|
| 97 | struct task_s *nxt_task; |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | // the task waits this objects: |
|---|
| 101 | struct v2lsem *waiting; |
|---|
| 102 | #if 0 |
|---|
| 103 | pthread_mutex_t *waiting_m; |
|---|
| 104 | #endif |
|---|
| 105 | } task_t; |
|---|
| 106 | #endif |
|---|
| 107 | //#define WIND_TCB task_t |
|---|
| 108 | |
|---|
| 109 | __END_DECLS |
|---|
| 110 | #endif |
|---|