µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
os-main.cpp File Reference

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 Default implementation of main().
 
void os_terminate_goodbye (void)
 Display statistics and say goodbye before terminating.
 

Variables

rtos::threados_main_thread
 

Function Documentation

◆ main()

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

Definition at line 113 of file os-main.cpp.

114{
115 using namespace os::rtos;
116
117 trace::printf ("\nµOS++ IIIe version " OS_STRING_RTOS_IMPL_VERSION "\n");
118 trace::printf ("Copyright (c) 2007-" OS_STRING_RTOS_IMPL_YEAR
119 " Liviu Ionescu\n");
120
121 port::scheduler::greeting ();
122
123 trace::printf ("Scheduler frequency: %u ticks/sec\n",
125 trace::printf ("Default stack size: %u bytes\n",
126 thread::stack::default_size ());
127#if defined(OS_HAS_INTERRUPTS_STACK)
128 trace::printf ("Interrupts stack size: %u bytes\n",
129 interrupts::stack ()->size ());
130#endif /* defined(OS_HAS_INTERRUPTS_STACK) */
131
132#if defined(__clang__)
133 trace::printf ("Built with clang " __VERSION__);
134#else
135 trace::printf ("Built with GCC " __VERSION__);
136#endif
137
138#if defined(__EXCEPTIONS)
139 trace::printf (", with exceptions");
140#else
141 trace::printf (", no exceptions");
142#endif
143 trace::puts ("\n");
144
145 scheduler::initialize ();
146
147 // Store the parameters in the static structure, to be used by os_main().
148 main_args.argc = argc;
149 main_args.argv = argv;
150
151#if defined(OS_EXCLUDE_DYNAMIC_MEMORY_ALLOCATIONS)
152
153 // Running the constructor manually has the additional advantage of
154 // not registering any destructor, and for main this is important,
155 // since the destructors are executed on its context, and it cannot
156 // destruct itself.
157 new (&os_main_thread_)
158 main_thread{ "main", reinterpret_cast<thread::func_t> (_main_trampoline),
159 nullptr };
160
161 os_main_thread = reinterpret_cast<rtos::thread*> (&os_main_thread_);
162
163#else
164
165 thread::attributes attr = thread::initializer;
167#pragma GCC diagnostic push
168#if defined(__clang__)
169#pragma clang diagnostic ignored "-Wcast-function-type-strict"
170#endif
171 os_main_thread = new thread (
172 "main", reinterpret_cast<thread::func_t> (_main_trampoline), nullptr,
173 attr);
174#pragma GCC diagnostic pop
175
176#endif /* defined(OS_EXCLUDE_DYNAMIC_MEMORY_ALLOCATIONS) */
177
178#if !defined(OS_USE_RTOS_PORT_SCHEDULER)
180#endif /* !defined(OS_USE_RTOS_PORT_SCHEDULER) */
181
182 // Execution will proceed to first registered thread, possibly
183 // "idle", which will immediately lower its priority,
184 // and at a certain moment will reach os_main().
185 scheduler::start ();
186
187 /* NOTREACHED */
188}
static constexpr uint32_t frequency_hz
SysTick frequency in Hz.
Definition os-clocks.h:471
Thread attributes.
Definition os-thread.h:800
std::size_t th_stack_size_bytes
Size of the user defined storage for the thread stack, in bytes.
Definition os-thread.h:861
POSIX compliant thread, using the default RTOS allocator.
Definition os-thread.h:251
void *(*)(func_args_t args) func_t
Type of thread function.
Definition os-thread.h:423
Standard thread.
#define OS_INTEGER_RTOS_MAIN_STACK_SIZE_BYTES
Define the main thread stack size, in bytes.
void os_startup_create_thread_idle(void)
Create the idle thread.
int puts(const char *s)
Write the string and a line terminator to the trace device.
Definition trace.cpp:102
int printf(const char *format,...)
Write a formatted string to the trace device.
Definition trace.cpp:59
RTOS namespace.
Definition os-flags.h:37
rtos::thread * os_main_thread
Definition os-main.cpp:92
#define OS_STRING_RTOS_IMPL_YEAR
Definition os-versions.h:42
#define OS_STRING_RTOS_IMPL_VERSION
Definition os-versions.h:44

References os::rtos::clock_systick::frequency_hz, OS_INTEGER_RTOS_MAIN_STACK_SIZE_BYTES, os_main_thread, os_startup_create_thread_idle(), OS_STRING_RTOS_IMPL_VERSION, OS_STRING_RTOS_IMPL_YEAR, os::trace::printf(), os::trace::puts(), and os::rtos::thread::attributes::th_stack_size_bytes.

Referenced by _start().

Variable Documentation

◆ os_main_thread

rtos::thread * os_main_thread

Definition at line 92 of file os-main.cpp.

Referenced by main(), and os_terminate_goodbye().