mirror of
https://gitlab.com/d3tn/ud3tn.git
synced 2026-08-14 12:43:26 +02:00
In order to properly clean up all resources allocated by threads, we need to join the non-detached threads. This is not possible within the `sigaction` exit handler function. For this reason, the termination logic is changed to use `sigwait`. In addition, SIGALRM is added to the list of handled signals and SIGUSR1, SIGUSR2 are ignored. Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
51 lines
1.4 KiB
C
51 lines
1.4 KiB
C
// SPDX-License-Identifier: BSD-3-Clause OR Apache-2.0
|
|
/*
|
|
* hal_task.h
|
|
*
|
|
* Description: contains the definitions of the hardware abstraction
|
|
* layer interface for thread-related functionality
|
|
*
|
|
*/
|
|
|
|
#ifndef HAL_TASK_H_INCLUDED
|
|
#define HAL_TASK_H_INCLUDED
|
|
|
|
#include "ud3tn/common.h"
|
|
#include "ud3tn/result.h"
|
|
|
|
#include "platform/hal_types.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
|
|
/**
|
|
* @brief hal_task_create Creates a new task in the underlying OS.
|
|
* @param task_function Pointer to the task function. When it terminates, the
|
|
* task will terminate cleanly as well
|
|
* @param task_parameters Arbitrary data that is passed to the created task
|
|
* @param detach Indicates whether the created thread should be detached
|
|
* @param thread_id Pointer to the identifier of the created thread.
|
|
* @return a ud3tn_result indicating whether the operation was successful or not
|
|
*/
|
|
enum ud3tn_result hal_task_create(
|
|
void (*task_function)(void *),
|
|
void *task_parameters,
|
|
bool detach,
|
|
TaskIdentifier_t *thread_id);
|
|
|
|
/**
|
|
* @brief hal_task_start_scheduler Starts the task scheduler of the underlying
|
|
* OS infrastructure (if necessary).
|
|
*/
|
|
enum ud3tn_result hal_task_start_scheduler(void);
|
|
|
|
/**
|
|
* @brief hal_task_delay Blocks the calling task for the specified time.
|
|
* @param delay The delay in milliseconds
|
|
*/
|
|
void hal_task_delay(int delay);
|
|
|
|
|
|
#endif /* HAL_TASK_H_INCLUDED */
|