Xenomai 3.3.2
Loading...
Searching...
No Matches
task.h
1/*
2 * Copyright (C) 2011 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 _ALCHEMY_TASK_H
20#define _ALCHEMY_TASK_H
21
22#include <sched.h>
23#include <semaphore.h>
24#include <errno.h>
25#include <boilerplate/list.h>
26#include <copperplate/syncobj.h>
27#include <copperplate/threadobj.h>
28#include <copperplate/registry.h>
29#include <copperplate/cluster.h>
30#include <alchemy/task.h>
31
32struct alchemy_task {
33 char name[XNOBJECT_NAME_LEN];
34 int mode;
35 cpu_set_t affinity;
36 int suspends;
37 struct syncobj sobj_msg;
38 int flowgen;
39 struct threadobj thobj;
40 struct clusterobj cobj;
41 void (*entry)(void *arg);
42 void *arg;
43 RT_TASK self;
44 struct fsobj fsobj;
45};
46
47struct alchemy_task_wait {
48 struct RT_TASK_MCB request;
49 struct RT_TASK_MCB reply;
50};
51
52#define task_magic 0x8282ebeb
53
54static inline struct alchemy_task *alchemy_task_current(void)
55{
56 struct threadobj *thobj = threadobj_current();
57
58 if (thobj == NULL ||
59 threadobj_get_magic(thobj) != task_magic)
60 return NULL;
61
62 return container_of(thobj, struct alchemy_task, thobj);
63}
64
65struct alchemy_task *get_alchemy_task(RT_TASK *task, int *err_r);
66
67struct alchemy_task *get_alchemy_task_or_self(RT_TASK *task, int *err_r);
68
69void put_alchemy_task(struct alchemy_task *tcb);
70
71static inline int check_task_priority(int prio)
72{ /* FIXME: HIPRIO is lower over Mercury */
73 return prio < T_LOPRIO || prio > T_HIPRIO ? -EINVAL : 0;
74}
75
76extern struct syncluster alchemy_task_table;
77
78#endif /* _ALCHEMY_TASK_H */