Statistics
| Branch: | Revision:

urtware / doc / classdiagrams / osal.uml @ 2d315870

History | View | Annotate | Download (12.3 KB)

1
/'
2
µRtWare is a lightweight publish/subscribe middleware for real-time
3
applications. It was developed as part of the software habitat for the
4
Autonomous Mini Robot [1] (AMiRo) but can be used for other purposes as well.
5

    
6
Copyright (C) 2018..2020  Thomas Schöpping et al.
7

    
8
This program is free software: you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation, either version 3 of the License, or
11
(at your option) any later version.
12

    
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
GNU General Public License for more details.
17

    
18
You should have received a copy of the GNU General Public License
19
along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
'/
21

    
22
/'### INTRO ##################################################################'/
23

    
24
@startuml
25

    
26
title **µRtWare**\nOperating System Abstraction Layer (OSAL)
27

    
28
!include ./functions.iuml
29

    
30
/'### ENTITIES ###############################################################'/
31

    
32
!startsub ENTITIES
33

    
34
/' OS time measurement feature. '/
35
$group("time") {
36
  /' OS time type with arbitrary resolution. '/
37
  $type("urt_osTime_t") {
38
      'Converts an OS time to 64 bit microsecond precise value.
39
    + {method} urtTime2Us (t : urt_osTime_t*) : uint64_t
40
      'Retrieves the current time.
41
    + {method} urtTimeNow (void) : urt_osTime_t
42
      'Increase a system time object.
43
    + {method} urtTimeAddUs (time : urt_osTime_t*, offset : uint32_t) : urt_osTime_t*
44
  }
45
}
46

    
47
/' OS mutex lock feature. '/
48
$group("mutex") {
49
  /' OS mutex lock interface. '/
50
  $type("urt_osMutex_t") {
51
      'Initializes a urt_osMutex_t object.
52
    + {method} urtMutexInit (mutex : urt_osMutex_t*) : void
53
      'Block the thread until the mutex could be locked.
54
    + {method} urtMutexLock (mutex : urt_osMutex_t*) : void
55
      'Tries to lock the mutex, but does not block but immediately returns an indicator.
56
    + {method} urtMutexTryLock (mutex : urt_osMutex_t*) : bool
57
      'Unlocks a previously locked mutex.
58
    + {method} urtMutexUnlock (mutex : urt_osMutex_t*) : void
59
  }
60
}
61

    
62
/' OS condition variable feature. '/
63
$group("condition variable") {
64
  /' Return type for the wait function on condition variables. '/
65
  $enumeration("urt_osCondvarWaitStatus_t") {
66
      'The condition variable has been signaled.
67
    URT_CONDVAR_WAITSTATUS_SIGNAL = 1
68
      'The condition variable has been broadcasted.
69
    URT_CONDVAR_WAITSTATUS_BROADCAST = 2
70
      'The wait function timed out.
71
    URT_CONDVAR_WAITSTATUS_TIMEOUT = 0
72
  }
73

    
74
  /' Condition variable interface. '/
75
  $type("urt_osCondvar_t") {
76
      'Initializes a urt_osCondvar_t object.
77
    + {method} urtCondvarInit (condvar : urt_osCondvar_t*) : void
78
      'Signals one thread that is waiting for the condition variable.
79
    + {method} urtCondvarSignal (condvar : urt_osCondvar_t*) : void
80
      'Signals all threads that are waiting for the condition variable.
81
    + {method} urtCondvarBroadcast (condvar : urt_osCondvar_t*) : void
82
      'Waits for the condition variable.
83
    + {method} urtCondvarWait (condvar : urt_osCondvar_t*, mutex : urt_osMutex_t*, timeout : urt_delay_t) : urt_osCondvarWaitStatus_t
84
  }
85
}
86

    
87
/' OS timer feature. '/
88
$group("timer") {
89
  /' Timer callback definition. '/
90
  $type("urt_osTimerCallback_t") {
91
    urt_osTimerCallback_t (parameter : void*) : void
92
  }
93

    
94
  /' OS timer interface. '/
95
  $type("urt_osTimer_t") {
96
      'Initializes an urt_osTimer_t object.
97
    + {method} urtTimerInit (timer : urt_osTimer_t*) : void
98
      'Sets the timer to a specified delay with specified callback and arguments.
99
    + {method} urtTimerSet (timer : urt_osTimer_t*, delay : urt_delay_t, callback : urt_osTimerCallback_t*, parameter : void*) : urt_status_t
100
      'Sets the timer to a specified period with specified callback and arguments.
101
    + {method} urtTimerSetPeriodic (timer : urt_osTimer_t*, period : urt_delay_t, callback : urt_osTimerCallback_t*, parameter : void*) : urt_status_t
102
      'Resets the timer.
103
    + {method} urtTimerReset (timer : urt_osTimer_t*) : urt_status_t
104
      'Check whether the timer is already armed.
105
    + {method} urtTimerIsArmed (timer : urt_osTimer_t*) : bool
106
  }
107
} /'condition variable'/
108

    
109
/' OS thread feature. '/
110
$group("thread") {
111
  /' Thread priority type. '/
112
  $type("urt_osThreadPrio_t") {
113
      'Minimum priority for low priority threads.
114
    URT_THREAD_PRIO_LOW_MIN
115
      'Maximum priority for low priority threads.
116
    URT_THREAD_PRIO_LOW_MAX
117
      'Minimum priority for normal priority threads.
118
    URT_THREAD_PRIO_NORMAL_MIN
119
      'Maximum priority for normal priority threads.
120
    URT_THREAD_PRIO_NORMAL_MAX
121
      'Minimum priority for high priority threads.
122
    URT_THREAD_PRIO_HIGH_MIN
123
      'Maximum priority for high priority threads.
124
    URT_THREAD_PRIO_HIGH_MAX
125
      'Minimum priority for real-time threads.
126
    URT_THREAD_PRIO_RT_MIN
127
      'Maximum priority for real-time threads.
128
    URT_THREAD_PRIO_RT_MAX
129
  }
130

    
131
  /' Thread main function type. '/
132
  $type("urt_osThreadFunction_t") {
133
    urt_osThreadFunction_t (arg : void*) : void
134
  }
135

    
136
  /' Thread terminate signals. '/
137
  $enumeration("urt_osThreadTerminateSignal_t") {
138
      'Signal to request termination asap.
139
    URT_THREAD_TERMINATE_REQUEST = 15
140
      'Signal to kill a thread immediately.
141
    URT_THREAD_TERMINATE_KILL = 9
142
  }
143

    
144
  /' Thread execution states. '/
145
  $enumeration("urt_osThreadState_t") {
146
      'Thread has not been started yet.
147
    URT_THREAD_STATE_INACTIVE = 0
148
      'Thread is currently being executed.
149
    URT_THREAD_STATE_RUNNING = 1
150
      'Thread is ready but waiting to be scheduled.
151
    URT_THREAD_STATE_READY = 2
152
      'Thread is actively sleeping.
153
    URT_THREAD_STATE_SLEEPING = 3
154
      'Thread has ben suspended explicitely.
155
    URT_THREAD_STATE_SUSPENDED = 4
156
      'Thread is waiting for something (e.g. Mutex, event, etc.).
157
    URT_THREAD_STATE_WAITING = 5
158
      'Thread has terminated.
159
    URT_THREAD_STATE_TERMINATED = 6
160
  }
161

    
162
  /' OS thread interface. '/
163
  $type("urt_osThread_t") {
164
     'Maximum sleep interval in seconds (as float).
165
    URT_THREAD_SLEEP_MAX : float
166
      'Maximum sleep interval in seconds.
167
    URT_THREAD_SSLEP_MAX : urt_delay_t
168
      'Maximum sleep interval in milliseconds.
169
    URT_THREAD_MSLEEP_MAX : urt_delay_t
170
      'Maximum sleep interval in microseconds.
171
    URT_THREAD_USLEEP_MAX : urt_delay_t
172
    --
173
      'Macro to setup working area as static variable (handles alignment if required).
174
    + {method} URT_THREAD_MEMORY (varname, stacksize)
175
    ..
176
      'Initializes an urt_osThread_t object.
177
    + {method} urtThreadInit (memory : void*, size : size_t, func : urt_osThreadFunction_t*) : urt_osThread_t*
178
      'Starts a thread.
179
    + {method} urtThreadStart (thread : urt_osThread_t*, prio : urt_osThreadPrio_t, arg : void*) : void
180
      'The calling threads yields.
181
    + {method} urtThreadYield (void) : void
182
      'Retrieves the priority of the calling thread.
183
    + {method} urtThreadGetPriority (void) : urt_osThreadPrio_t
184
      'Sets the priority of the calling thread.
185
    + {method} urtThreadSetPriority (prio : urt_osThreadPrio_t) : void
186
      'Suspends a thread so it will no longer be executed.
187
    + {method} urtThreadSuspend (thread : urt_osThread_t*) : void
188
      'Wakes a suspended thread.
189
    + {method} urtThreadResume (thread : urt_osThread_t*) : urt_status_t
190
      'Suspends the calling thread for the specified time.
191
    + {method} urtThreadSleep (seconds : float) : void
192
      'Suspends the calling thread for the specified time.
193
    + {method} urtThreadSSleep (seconds : urt_delay_t) : void
194
      'Suspends the calling thread for the specified time.
195
    + {method} urtThreadMSleep (milliseconds : urt_delay_t) : void
196
      'Suspends the calling thread for the specified time.
197
    + {method} urtThreadUSleep (microseconds : urt_delay_t) : void
198
      'Suspends the calling thread until the specified time.
199
    + {method} urtThreadSleepUntil (time : urt_osTime_t) : void
200
      'The calling thread exits execution (terminates).
201
    + {method} urtThreadExit (void) : void
202
      'Terminates a specified thread.
203
    + {method} urtThreadTerminate (thread : urt_osThread_t*, sig : urt_osThreadTerminateSignal_t) : void
204
      'Waits until the specified thread terminates.
205
    + {method} urtThreadJoin (thread : urt_osThread_t*) : void
206
      'Retrieves the execution state of the specified thread.
207
    + {method} urtThreadGetState (thread : urt_osThread_t*) : urt_osThreadState_t
208
      'Retrieves the calling thread itself.
209
    + {method} urtThreadGetSelf (void) : urt_osThread_t*
210
      'Retrieves the first child of a thread or ""NULL"".
211
    + urtThreadGetChildren (thread : urt_osThread_t*) : urt_osThread_t*
212
      'Retrieves a sibling (next child in a list) of the thread or ""NULL"".
213
    + urtThreadGetSibling (thread : urt_osThread_t*) : urt_osThread_t*
214
      'Retrieves the parent thread.
215
    + urtThreadGetParent (thread : urt_osThread_t*) : urt_osThread_t*
216
  }
217
} /'thread'/
218

    
219
/' OS event feature. '/
220
$group("events") {
221
  /' OS event mask type. '/
222
  $type("urt_osEventMask_t") {
223
      'The event mask, which will be handled with maximum priority by the event system.
224
    URT_EVENTMASK_MAXPRIO : urt_osEventMask_t
225
  }
226

    
227
  /' OS event flag type. '/
228
  $type("urt_osEventFlags_t") {
229
  }
230

    
231
  /' OS event wait type. '/
232
  $enumeration("urt_osEventWait_t") {
233
      'Wait for exactly one event.
234
    URT_EVENT_WAIT_ONE = 0
235
      'Wait for at least one event.
236
    URT_EVENT_WAIT_ANY = 1
237
      'Wait for all events.
238
    URT_EVENT_WAIT_ALL = 2
239
  }
240

    
241
  /' OS event listener interface. '/
242
  $type("urt_osEventListener_t") {
243
      'Initializes an urt_osEventListener_t object.
244
    + {method} urtEventListenerInit (listener : urt_osEventListener_t*) : void
245
      'Retrieves the flags of the event listener.
246
    + {method} urtEventListenerGetFlags (listener : urt_osEventListener_t*) : urt_osEventFlags_t
247
      'Retrieves and clears the flags of the event listener.
248
    + {method} urtEventListenerClearFlags (listener : urt_osEventListener_t*) : urt_osEventFlags_t
249
  }
250

    
251
  /' OS event source interface. '/
252
  $type("urt_osEventSource_t") {
253
      'Initializes an urt_osEventSource_t object.
254
    + {method} urtEventSourceInit (source : urt_osEventSource_t*) : void
255
      'Emits an event.
256
    + {method} urtEventSourceBroadcast (source : urt_osEventSource_t*, flags : urt_osEventFlags_t) : void
257
  }
258

    
259
  /' Not a class/type but a set of static event-related functions. '/
260
  $function("urt_events") {
261
      'Registers a lister to a source.
262
    + {method} urtEventRegister (source : urt_osEventSource_t*, listener : urt_osEventListener_t*, mask : urt_osEventMask_t, flags : urt_osEventFlags_t) : urt_status_t
263
      'Unregisters a listener from a source.
264
    + {method} urtEventUnregister (source _ urt_osEventSource_t*, listener : urt_osEventListener_t*) : urt_status_t
265
      'Blocks the thread until any event occurs or the timeout expires.
266
    + {method} urtEventWait (mask : urt_osEventMask_t, type : urt_osEventWait_t, timeout : urt_delay_t) : urt_osEventMask_t
267
  }
268
} /'events'/
269

    
270
/' OS streams feature. '/
271
$group("streams") {
272
  /' Not a class/type but a set of output-related functions. '/
273
  $function("urt_streams") {
274
      'Prints a formatted string to the standard output stream (stdout).
275
    + {method} urtPrintf(fmt : char*, ... ) : int
276
      'Prints a formatted string to the standard error stream (stderr).
277
    + {method} urtErrPrintf(fmt : char*, ... ) : int
278
  }
279
}
280

    
281
/' OS debugging feature. '/
282
$group("debug") {
283
  /' Just a function for debugging. '/
284
  $function("urt_debug") {
285
      'Checks the condition in debug mode.
286
    + {method} urtDebugAssert(condition : bool) : void
287
  }
288
}
289

    
290
!endsub
291

    
292
/'### DEPENDENCIES & LAYOUT ##################################################'/
293

    
294
!startsub DEPENDENCIES
295

    
296
urt_osCondvar_t ..> urt_osCondvarWaitStatus_t
297
urt_osCondvar_t .> urt_osMutex_t
298

    
299
urt_osTimer_t ..> urt_osTimerCallback_t
300

    
301
urt_osThread_t ..> urt_osThreadPrio_t
302
urt_osThread_t ..> urt_osThreadFunction_t
303
urt_osThread_t ..> urt_osThreadTerminateSignal_t
304
urt_osThread_t ..> urt_osThreadState_t
305
urt_osThread_t .> urt_osTime_t
306

    
307
urt_osEventListener_t ..> urt_osEventFlags_t
308
urt_osEventSource_t ..> urt_osEventFlags_t
309
urt_events ..> urt_osEventSource_t
310
urt_events ..> urt_osEventListener_t
311
urt_events ..> urt_osEventMask_t
312
urt_events ..> urt_osEventFlags_t
313
urt_events ..> urt_osEventWait_t
314

    
315
!endsub
316

    
317
/'### OUTRO ##################################################################'/
318

    
319
@enduml
320