Target Abstraction

In the Middleware layer, the Target Abstraction offers an abstraction of the target services. It gives the possibility to implement a behavior that is independent of any target.

See Also
Middleware Layer

The Target Abstraction delivers realtime services on which the model can rely. These services are the following:

Service Description
Scheduling Service Provides a mechanism of threading. It is the smallest sequence of the programmed instructions that can be managed independently. It has its own program counter, register specify, and stack space.

The interface is standard. Here is an example of a scheduling mechanism based on thread.

/** Create a new Thread and attach a function pointer */
threadId tal_CreateThread(void *(*taskPtr)(void *), void * arg);

/** Resume a pending Thread */
threadId tal_GetCurrentThreadId(void);

/** Resume a pending Thread */
void tal_ResumeThread(threadId id);

/** Suspend a running Thread */
void tal_SuspendThread(threadId id);

/** Exit a Thread */
status tal_ExitThread(threadId id);

Timing Service Provides mechanism to monitor the time. It creates and defines a timer

The interface is standard. Here is an example:

/** Return the current time of the system since the application startup in second */
double tal_GetTime(void);

/** Create a timer.
 * The timer can call a callback function <TO BE CONFIRMED: in a new thread> upon timer expiration
 * fct can be NULL if no function needs to be called when timer expires
 * arg can be NULL if no argument needs to be transmitted to the callback function
 */
TimerId tal_CreateTimer(void* (*fct)(void*), void* arg);

/** Set the period of the timer and start it.
 * The function returns immediately and the caller need to call tal_WaitTimer() to wait for the timer expiration */
status tal_SetTimer(TimerId id, TimeVal value, bool periodic);

/** Suspend the current thread and wait for the timer expiration */
status tal_WaitTimer(timerId id);

/** Cancel a running timer */
status tal_CancelTimer(timerId id);

/** Delete a timer */
status tal_DeleteTimer(TimerId id);

As an example, the timing mechanism implementation can be based on POSIX timer.

Example of POSIX timer usage for implementation purpose:

https://gist.github.com/cirocosta/ab2b73b2e1bb34b83f52

https://man7.org/linux/man-pages/man2/timer_create.2.html

Synchronization Service Mutex provides a mutual exclusion mechanism.

Semaphore provides a controlled access by a limited number of threads.

Messaging Service

Provides interthreading message.

Tracing Service

Provides functions for tracing purpose.

The interface is standard. Here is an example:

/** Print a message in console via a thread safe implementation of printf */
void tal_printf(const char* str, ...);

Hardware Resources Service

Provides access to GPIO and memory.