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 12/23/15 at 20:44:02

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
RevLine 
[0074691a]1/*
2  ------------------------------------------------------------------------
3
4  COPYRIGHT (c) 1997
5  Objective Design Systems Ltd Pty (ODS)
6  All rights reserved (R) Objective Design Systems Ltd Pty
[1b4f2b30]7
[0074691a]8  The license and distribution terms for this file may be found in the
9  file LICENSE in this distribution or at
[c499856]10  http://www.rtems.org/license/LICENSE.
[0074691a]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.
[1b4f2b30]30
[0074691a]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
[1c9a4c75]70  // only the first 4 characters of the name are taken
[0074691a]71
72  // creates a task
73  rtemsTask(const char* name,
74            const rtems_task_priority initial_priority,
[600a241e]75            const uint32_t stack_size,
[0074691a]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
[600a241e]84  rtemsTask(const char *name, const uint32_t node = RTEMS_SEARCH_ALL_NODES);
[0074691a]85
86  // copy and default constructors
87  rtemsTask(const rtemsTask& task);
88  rtemsTask();
[1b4f2b30]89
[0074691a]90  // only the creator's destructor will delete the actual object
91  virtual ~rtemsTask();
[1b4f2b30]92
[0074691a]93  // create or destroy (delete) the task
94  virtual const rtems_status_code create(const char* name,
95                                         const rtems_task_priority initial_priority,
[600a241e]96                                         const uint32_t stack_size,
[0074691a]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,
[600a241e]108                                          const uint32_t node = RTEMS_SEARCH_ALL_NODES);
[1b4f2b30]109
[0074691a]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);
[1b4f2b30]119
[0074691a]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);
[1b4f2b30]125
[0074691a]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; }
[1b4f2b30]130
[0074691a]131protected:
132
133  // task entry point
134  virtual void body(rtems_task_argument argument);
[1b4f2b30]135
[0074691a]136private:
137
138  // make the object to point to RTEMS_SELF
139  void make_self();
[1b4f2b30]140
[0074691a]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;
[1b4f2b30]148
[0074691a]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;
[1b4f2b30]155
[0074691a]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.