source: rtems/c/src/librtems++/include/rtems++/rtemsTask.h @ d5154d0f

5
Last change on this file since d5154d0f was d5154d0f, checked in by Aun-Ali Zaidi <admin@…>, on Dec 23, 2015 at 8:44:02 PM

api: Remove deprecated Notepads

Notepads where a feature of RTEMS' tasks that simply functioned in
the same way as POSIX keys or threaded local storage (TLS). They were
introduced well before per task variables, which are also deprecated,
and were barely used in favor of their POSIX alternatives.

In addition to their scarce usage, Notepads took up unnecessary memory.
For each task:

  • 16 32-bit integers were allocated.
  • A total of 64 bytes per task per thread.

This is especially critical in low memory and safety-critical applications.

They are also defined as uint32_t, and therefore are not guaranteed to
hold a pointer.

Lastly, they are not portable solutions for SMP and uniprocessor systems,
like POSIX keys and TLS.

updates #2493.

  • Property mode set to 100644
File size: 5.5 KB
Line 
1/*
2  ------------------------------------------------------------------------
3
4  COPYRIGHT (c) 1997
5  Objective Design Systems Ltd Pty (ODS)
6  All rights reserved (R) Objective Design Systems Ltd Pty
7
8  The license and distribution terms for this file may be found in the
9  file LICENSE in this distribution or at
10  http://www.rtems.org/license/LICENSE.
11
12  ------------------------------------------------------------------------
13
14  rtemsTask class.
15
16  This class allows the user to create a RTEMS task, or to access and
17  manage an already existing task.
18
19  The first constructor with the task parameters creates a RTEMS task
20  object. The destructor of this object also deletes the task
21  object. The last status code should be checked after construction to
22  see if the create completed successfully.
23
24  The second constructor connects to an existing task object. The last
25  status code should be checked after construction to see if the
26  task existed.
27
28  The third constructor is a copy constructor. Connects to an existing
29  object which is in scope.
30
31  The RTEMS id is set to self in the default construction.
32
33  The creation of the task object can be defered until after
34  construction. This allows for static task objects to be created.
35
36  RTEMS should be initialised before static constructors run, how-ever
37  threads will will not. You need to watch the start-order.
38
39  A task object can change state from an owner of a task to being
40  connected to a task.
41
42  Task objects connected to another task do not receive notification
43  when the task connected to changes state.
44
45  The sleep methods operate on the current thread not the task
46  reference by this object.
47
48  Mode control is through the rtemsTaskMode class.
49
50  ------------------------------------------------------------------------ */
51
52#if !defined(_rtemsTask_h_)
53#define _rtemsTask_h_
54
55#include <rtems++/rtemsStatusCode.h>
56
57/* ----
58    rtemsTask
59*/
60
61class rtemsTask
62  : public rtemsStatusCode
63{
64public:
65  enum FloatingPoint { fpoff = RTEMS_NO_FLOATING_POINT,
66                       fpon = RTEMS_FLOATING_POINT };
67  enum Scope { local = RTEMS_LOCAL,
68               global = RTEMS_GLOBAL };
69
70  // only the first 4 characters of the name are taken
71
72  // creates a task
73  rtemsTask(const char* name,
74            const rtems_task_priority initial_priority,
75            const uint32_t stack_size,
76            const rtems_mode preemption = RTEMS_NO_PREEMPT,
77            const rtems_mode timeslice = RTEMS_NO_TIMESLICE,
78            const rtems_mode asr = RTEMS_NO_ASR,
79            const rtems_interrupt_level interrupt_level = 0,
80            const FloatingPoint floating_point = fpoff,
81            const Scope scope = local);
82
83  // connects to a task
84  rtemsTask(const char *name, const uint32_t node = RTEMS_SEARCH_ALL_NODES);
85
86  // copy and default constructors
87  rtemsTask(const rtemsTask& task);
88  rtemsTask();
89
90  // only the creator's destructor will delete the actual object
91  virtual ~rtemsTask();
92
93  // create or destroy (delete) the task
94  virtual const rtems_status_code create(const char* name,
95                                         const rtems_task_priority initial_priority,
96                                         const uint32_t stack_size,
97                                         const rtems_mode preemption = RTEMS_NO_PREEMPT,
98                                         const rtems_mode timeslice = RTEMS_NO_TIMESLICE,
99                                         const rtems_mode asr = RTEMS_NO_ASR,
100                                         const rtems_interrupt_level interrupt_level = 0,
101                                         const FloatingPoint floating_point = fpoff,
102                                         const Scope scope = local);
103  virtual const rtems_status_code destroy();
104
105  // connect to an existing task object, will not be the owner
106  const rtemsTask& operator=(const rtemsTask& task);
107  virtual const rtems_status_code connect(const char *name,
108                                          const uint32_t node = RTEMS_SEARCH_ALL_NODES);
109
110  // run control
111  virtual const rtems_status_code start(const rtems_task_argument argument);
112  virtual const rtems_status_code restart(const rtems_task_argument argument);
113  virtual const rtems_status_code suspend();
114  virtual const rtems_status_code resume();
115
116  // sleep control, the timeout is in micro-seconds
117  virtual const rtems_status_code wake_after(const rtems_interval micro_secs);
118  virtual const rtems_status_code wake_when(const rtems_time_of_day& tod);
119
120  // priority control
121  const rtems_status_code get_priority(rtems_task_priority& priority);
122  const rtems_status_code set_priority(const rtems_task_priority priority);
123  const rtems_status_code set_priority(const rtems_task_priority priority,
124                                       rtems_task_priority& old_priority);
125
126  // object id, and name
127  const rtems_id id_is() const { return id; }
128  const rtems_name name_is() const { return name; }
129  const char *name_string() const { return name_str; }
130
131protected:
132
133  // task entry point
134  virtual void body(rtems_task_argument argument);
135
136private:
137
138  // make the object to point to RTEMS_SELF
139  void make_self();
140
141  // task name
142  rtems_name name;
143  char name_str[5];
144
145  // owner, true if this object owns the task
146  // will delete the task when it destructs
147  bool owner;
148
149  // the rtems id, object handle
150  rtems_id id;
151
152  // the argument for the task, this class uses the actual argument
153  // passed to RTEMS
154  rtems_task_argument argument;
155
156  // common entry point to the task
157  static rtems_task origin(rtems_task_argument argument);
158};
159
160#endif  // _rtemsTask_h_
Note: See TracBrowser for help on using the repository browser.