Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
os.c File Reference
#include <stdint.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/select.h>
#include <sched.h>
#include <time.h>
#include <signal.h>
#include "nmranet_config.h"
#include "utils/macros.h"
#include "os/os.h"
#include "os/os_private.h"

Go to the source code of this file.

Macros

#define _DEFAULT_SOURCE
 
#define OS_INLINE   extern
 Forces one definition of each inline function to be compiled.
 
#define DELETED_TASK_MAGIC   0xb5c5d5e5
 This magic value is written to a task's taskList entry in order to signal the idle task to pick it out of the taskList structure.
 

Functions

int os_thread_create (os_thread_t *thread, const char *name, int priority, size_t stack_size, void *(*start_routine)(void *), void *arg)
 Create a thread.
 
long long hw_get_partial_tick_time_nsec (void)
 Implement this function to read timing more accurately than 1 msec in FreeRTOS.
 
long long os_get_time_monotonic (void)
 Get the monotonic time since the system started.
 
ssize_t os_get_free_heap ()
 
int ignore_fn (void)
 This function does nothing.
 
int main (int argc, char *argv[])
 Entry point to program.
 

Variables

const char * STDIN_DEVICE
 default stdin
 
const char * STDOUT_DEVICE
 default stdout
 
const char * STDERR_DEVICE
 default stderr
 
int g_death_lineno
 Captures point of death (line).
 
const char * g_death_file
 Captures point of death (file).
 
long long rtcOffset = 0
 clock management
 

Detailed Description

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This file represents a C language abstraction of common operating system calls.

Author
Stuart W. Baker
Date
13 August 2012

Definition in file os.c.

Macro Definition Documentation

◆ _DEFAULT_SOURCE

#define _DEFAULT_SOURCE

Definition at line 36 of file os.c.

◆ DELETED_TASK_MAGIC

#define DELETED_TASK_MAGIC   0xb5c5d5e5

This magic value is written to a task's taskList entry in order to signal the idle task to pick it out of the taskList structure.

Definition at line 102 of file os.c.

◆ OS_INLINE

#define OS_INLINE   extern

Forces one definition of each inline function to be compiled.

Definition at line 40 of file os.c.

Function Documentation

◆ hw_get_partial_tick_time_nsec()

long long hw_get_partial_tick_time_nsec ( void  )
extern

Implement this function to read timing more accurately than 1 msec in FreeRTOS.

Default implementation does not provide more accuracy.

Definition at line 569 of file os.c.

◆ ignore_fn()

int ignore_fn ( void  )

This function does nothing.

It can be used to alias other symbols to it via linker flags, such as atexit().

Returns
0.

Definition at line 923 of file os.c.

◆ main()

int main ( int  argc,
char *  argv[] 
)

Entry point to program.

Parameters
argcnumber of command line arguments
argvarray of command line aguments
Returns
0, should never return

Definition at line 939 of file os.c.

◆ os_get_free_heap()

ssize_t os_get_free_heap ( void  )
Returns
the available heap or -1 if this operation is not supported.

Definition at line 914 of file os.c.

◆ os_get_time_monotonic()

long long os_get_time_monotonic ( void  )

Get the monotonic time since the system started.

Returns
time in nanoseconds since system start

Definition at line 571 of file os.c.

◆ os_thread_create()

int os_thread_create ( os_thread_t *  thread,
const char *  name,
int  priority,
size_t  stack_size,
void *(*)(void *)  start_routine,
void *  arg 
)

Create a thread.

Creates a thread.

Parameters
threadhandle to the created thread
namename of thread, NULL for an auto generated name
prioritypriority of created thread, 0 means default, lower numbers means lower priority, higher numbers mean higher priority
stack_sizesize in bytes of the created thread's stack
start_routineentry point of the thread
argentry parameter to the thread
Returns
0 upon success or error number upon failure

Definition at line 450 of file os.c.

Variable Documentation

◆ g_death_file

const char* g_death_file

Captures point of death (file).

Definition at line 95 of file os.c.

◆ g_death_lineno

int g_death_lineno

Captures point of death (line).

Definition at line 93 of file os.c.

◆ rtcOffset

long long rtcOffset = 0

clock management

Allows for OS abstracted access to time.

Definition at line 98 of file os.c.

◆ STDERR_DEVICE

const char* STDERR_DEVICE
extern

default stderr

Definition at line 45 of file Null.cxx.

◆ STDIN_DEVICE

const char* STDIN_DEVICE
extern

default stdin

Definition at line 39 of file Null.cxx.

◆ STDOUT_DEVICE

const char* STDOUT_DEVICE
extern

default stdout

Definition at line 42 of file Null.cxx.