Xenomai 3.3.2
Loading...
Searching...
No Matches
taskLib.h
1/*
2 * Copyright (C) 2008 Philippe Gerum <rpm@xenomai.org>.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 */
18
19#ifndef _VXWORKS_TASKLIB_H
20#define _VXWORKS_TASKLIB_H
21
22#include <copperplate/threadobj.h>
23#include <copperplate/registry.h>
24#include <copperplate/cluster.h>
25#include <vxworks/taskLib.h>
26
27struct wind_task_args {
28 FUNCPTR entry;
29 long arg0;
30 long arg1;
31 long arg2;
32 long arg3;
33 long arg4;
34 long arg5;
35 long arg6;
36 long arg7;
37 long arg8;
38 long arg9;
39};
40
41struct wind_task {
42 pthread_mutex_t safelock;
43 struct WIND_TCB *tcb;
44 struct WIND_TCB priv_tcb;
45 char name[XNOBJECT_NAME_LEN];
46 struct wind_task_args args;
47 struct threadobj thobj;
48 struct fsobj fsobj;
49 struct clusterobj cobj;
50 struct pvholder next;
51};
52
53#define do_each_wind_task(__task, __action) \
54 ({ \
55 __label__ out; \
56 int __ret; \
57 push_cleanup_lock(&wind_task_lock); \
58 read_lock(&wind_task_lock); \
59 if (!pvlist_empty(&wind_task_list)) \
60 pvlist_for_each_entry(__task, &wind_task_list, next) { \
61 threadobj_lock(&(__task)->thobj); \
62 __ret = (__action); \
63 if (__ret == -EIDRM) \
64 continue; \
65 threadobj_unlock(&(__task)->thobj); \
66 if (__ret) \
67 goto out; \
68 } \
69 read_unlock(&wind_task_lock); \
70 pop_cleanup_lock(&wind_task_lock); \
71 out: \
72 __ret; \
73 })
74
75int wind_task_get_priority(struct wind_task *task);
76
77#define task_magic 0x1a2b3c4d
78
79static inline struct wind_task *wind_task_current(void)
80{
81 struct threadobj *thobj = threadobj_current();
82
83 if (thobj == NULL ||
84 threadobj_get_magic(thobj) != task_magic)
85 return NULL;
86
87 return container_of(thobj, struct wind_task, thobj);
88}
89
90struct wind_task *get_wind_task(TASK_ID tid);
91
92struct wind_task *get_wind_task_or_self(TASK_ID tid);
93
94void put_wind_task(struct wind_task *task);
95
96int get_task_status(struct wind_task *task);
97
98extern struct cluster wind_task_table;
99
100extern struct pvlistobj wind_task_list;
101
102extern pthread_mutex_t wind_task_lock;
103
104extern int wind_time_slice;
105
106#endif /* _VXWORKS_TASKLIB_H */