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