OS Data Structures¶
Scalar Types¶
Many of the types used to communicate with NuttX are simple scalar types. These types are used to provide architecture independence of the OS from the application. The scalar types used at the NuttX interface include:
-
type
pid_t
¶
-
type
size_t
¶
-
type
sigset_t
¶
-
type
time_t
¶
Access to the errno
Variable¶
A pointer to the thread-specific errno
value is available through a
function call:
-
int *
__errno
(void)¶ __errno()
returns a pointer to the thread-specificerrno
value. Note that the symbolerrno
is defined to be__errno()
so that the usual access by referencing the symbolerrno
will work as expected.#include <errno.h> #define errno *__errno() int *__errno(void);
There is a unique, private
errno
value for each NuttX task. However, the implementation oferrno
differs somewhat from the use oferrno
in most multi-threaded process environments: In NuttX, each pthread will also have its own private copy oferrno
and theerrno
will not be shared between pthreads. This is, perhaps, non-standard but promotes better thread independence.- return
A pointer to the thread-specific
errno
value.
User Interface Structures¶
-
typedef int (*
main_t
)(int argc, char *argv[])¶
main_t
defines the type of a task entry point. main_t
is declared in
sys/types.h
.
-
struct
sched_param
¶
This structure is used to pass scheduling priorities to and from NuttX:
struct sched_param
{
int sched_priority;
};
-
struct
timespec
¶
This structure is used to pass timing information between the NuttX and a user application:
struct timespec
{
time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds */
};
-
struct
mq_attr
¶
This structure is used to communicate message queue attributes between NuttX and a MoBY application:
struct mq_attr {
size_t mq_maxmsg; /* Max number of messages in queue */
size_t mq_msgsize; /* Max message size */
unsigned mq_flags; /* Queue flags */
size_t mq_curmsgs; /* Number of messages currently in queue */
};
-
struct
sigaction
¶
The following structure defines the action to take for given signal:
struct sigaction
{
union
{
void (*_sa_handler)(int);
void (*_sa_sigaction)(int, siginfo_t *, void *);
} sa_u;
sigset_t sa_mask;
int sa_flags;
};
#define sa_handler sa_u._sa_handler
#define sa_sigaction sa_u._sa_sigaction
-
struct
siginfo
¶
-
type
siginfo_t
¶
The following types is used to pass parameters to/from signal handlers:
typedef struct siginfo
{
int si_signo;
int si_code;
union sigval si_value;
} siginfo_t;
-
union
sigval
¶
This defines the type of the struct siginfo si_value field and is used to pass parameters with signals.
union sigval
{
int sival_int;
void *sival_ptr;
};
-
struct
sigevent
¶
The following is used to attach a signal to a message queue to notify a task when a message is available on a queue.
struct sigevent
{
int sigev_signo;
union sigval sigev_value;
int sigev_notify;
};