F´ Flight Software - C/C++ Documentation
NASA-v1.5.0
A framework for building embedded system applications to NASA flight quality standards.
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Functions
a
b
c
d
g
h
i
m
r
s
t
v
w
Variables
Typedefs
Enumerations
Enumerator
a
b
c
f
h
i
l
m
n
o
p
s
t
v
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Variables
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Typedefs
c
t
u
w
Enumerations
b
c
d
e
f
g
h
i
m
o
p
q
s
t
w
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
w
Related Functions
a
b
c
f
g
h
l
p
r
s
t
Files
File List
File Members
All
_
a
b
c
d
f
g
h
i
k
l
m
n
p
r
s
t
u
v
w
Functions
f
i
m
s
u
Variables
_
c
f
i
l
p
t
Typedefs
Enumerations
Enumerator
a
c
d
f
i
m
p
r
s
t
w
Macros
a
c
d
f
g
h
i
k
l
m
n
p
r
s
t
u
v
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Task.cpp
Go to the documentation of this file.
1
#include <
Fw/Comp/ActiveComponentBase.hpp
>
2
#include <
Os/Task.hpp
>
3
#include <
Os/Baremetal/TaskRunner/BareTaskHandle.hpp
>
4
#include <
Fw/Types/Assert.hpp
>
5
#include <stdio.h>
6
namespace
Os
{
7
8
Task::Task
() :
9
m_handle(0),
10
m_identifier(0),
11
m_affinity(-1),
12
m_started(false),
13
m_suspendedOnPurpose(false)
14
{}
15
16
Task::TaskStatus
Task::start
(
const
Fw::StringBase
&name,
NATIVE_INT_TYPE
identifier,
NATIVE_INT_TYPE
priority,
NATIVE_INT_TYPE
stackSize, taskRoutine routine,
void
* arg,
NATIVE_INT_TYPE
cpuAffinity) {
17
//Get a task handle, and set it up
18
BareTaskHandle
* handle =
new
BareTaskHandle
();
19
if
(handle ==
NULL
) {
20
return
Task::TASK_UNKNOWN_ERROR
;
21
}
22
//Set handle memeber variables
23
handle->
m_enabled
=
true
;
24
handle->
m_priority
= priority;
25
handle->
m_routine
= routine;
26
handle->
m_argument
= arg;
27
//Register this task using our custom task handle
28
m_handle =
reinterpret_cast<
POINTER_CAST
>
(handle);
29
this->m_name =
"BR_"
;
30
this->m_name += name;
31
this->m_identifier = identifier;
32
// If a registry has been registered, register task
33
if
(Task::s_taskRegistry) {
34
Task::s_taskRegistry->addTask(
this
);
35
}
36
//Running the task the first time allows setup activities for the task
37
handle->
m_routine
(handle->
m_argument
);
38
return
Task::TASK_OK
;
39
}
40
41
Task::TaskStatus
Task::delay
(
NATIVE_UINT_TYPE
milliseconds)
42
{
43
//Task delays are a bad idea in baremetal tasks
44
return
Task::TASK_DELAY_ERROR
;
45
}
46
47
Task::~Task
() {
48
if
(this->m_handle) {
49
delete
reinterpret_cast<
BareTaskHandle
*
>
(this->m_handle);
50
}
51
// If a registry has been registered, remove task
52
if
(Task::s_taskRegistry) {
53
Task::s_taskRegistry->removeTask(
this
);
54
}
55
}
56
57
void
Task::suspend
(
bool
onPurpose) {
58
FW_ASSERT
(
reinterpret_cast<
BareTaskHandle
*
>
(this->m_handle) !=
NULL
);
59
reinterpret_cast<
BareTaskHandle
*
>
(this->m_handle)->m_enabled =
false
;
60
}
61
62
void
Task::resume
(
void
) {
63
FW_ASSERT
(
reinterpret_cast<
BareTaskHandle
*
>
(this->m_handle) !=
NULL
);
64
reinterpret_cast<
BareTaskHandle
*
>
(this->m_handle)->m_enabled =
true
;
65
}
66
67
bool
Task::isSuspended
(
void
) {
68
FW_ASSERT
(
reinterpret_cast<
BareTaskHandle
*
>
(this->m_handle) !=
NULL
);
69
return
!
reinterpret_cast<
BareTaskHandle
*
>
(this->m_handle)->m_enabled;
70
}
71
72
Task::TaskStatus
Task::join
(
void
**value_ptr) {
73
return
TASK_OK
;
74
}
75
76
}
Os
Definition:
File.cpp:7
Os::Task::suspend
void suspend(bool onPurpose=false)
suspend task
Definition:
Task.cpp:57
Os::BareTaskHandle::m_enabled
bool m_enabled
Save the priority.
Definition:
BareTaskHandle.hpp:19
Os::Task::TASK_UNKNOWN_ERROR
@ TASK_UNKNOWN_ERROR
unexpected error return value
Definition:
Task.hpp:22
Os::BareTaskHandle::m_argument
void * m_argument
Definition:
BareTaskHandle.hpp:25
Fw::StringBase
Definition:
StringType.hpp:23
Os::BareTaskHandle::m_priority
NATIVE_INT_TYPE m_priority
Function passed in to the task.
Definition:
BareTaskHandle.hpp:21
Task.hpp
Os::BareTaskHandle::m_routine
Task::taskRoutine m_routine
Argument input pointer.
Definition:
BareTaskHandle.hpp:23
Os::Task::Task
Task()
constructor
Definition:
Task.cpp:8
Os::Task::resume
void resume(void)
resume execution of task
Definition:
Task.cpp:62
Assert.hpp
ActiveComponentBase.hpp
Os::Task::TASK_OK
@ TASK_OK
message sent/received okay
Definition:
Task.hpp:19
Os::Task::TaskStatus
TaskStatus
Definition:
Task.hpp:18
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition:
BasicTypes.hpp:30
Os::Task::TASK_DELAY_ERROR
@ TASK_DELAY_ERROR
error trying to delay the task
Definition:
Task.hpp:24
FW_ASSERT
#define FW_ASSERT(...)
Definition:
Assert.hpp:9
Os::Task::delay
static TaskStatus delay(NATIVE_UINT_TYPE msecs)
delay the task
Definition:
Task.cpp:41
Os::Task::start
TaskStatus start(const Fw::StringBase &name, NATIVE_INT_TYPE identifier, NATIVE_INT_TYPE priority, NATIVE_INT_TYPE stackSize, taskRoutine routine, void *arg, NATIVE_INT_TYPE cpuAffinity=-1)
start the task
Definition:
Task.cpp:16
Os::Task::isSuspended
bool isSuspended(void)
check with OS to see if it is suspended already
Definition:
Task.cpp:67
Os::BareTaskHandle
Definition:
BareTaskHandle.hpp:14
Os::Task::~Task
virtual ~Task()
destructor
Definition:
Task.cpp:47
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition:
BasicTypes.hpp:29
BareTaskHandle.hpp
NULL
#define NULL
NULL.
Definition:
BasicTypes.hpp:100
Os::Task::join
TaskStatus join(void **value_ptr)
Wait for task to finish.
Definition:
Task.cpp:72
Os
Baremetal
Task.cpp
Generated by
1.8.19