Operating Systems for Embedded Computing (2011) - lab3
Operating Systems for Embedded Computing
Lab Assignment 3 - Minimal NXT real-time operating system
Within this lab assignment you have to design and implement a minimal operating system for the Lego NXT platform. You should implement a minimal real-time operating system with the following features:
- Threads (minimal dispatchter + API)
- Miminal memory management (at least static stack memory management for threads)
- A static priority-based, FIFO scheduler
- A sleep function, which suspends the current thread for a specified amount of milliseconds
Your operating system must at least support the following functions:
- void create_thread(void* entry_point, int stack_size, unsigned char priority, int* thread_id)
- Creates a new thread
- Starting with a call to entry_point
- With a stack as spezified by stack_size (you are allowed to demand a fixed stack size - always 512 Byte ...)
- The thread with the highest priority runs
- Returns an ID for the thread
- int get_thread_id()
- Returns the ID of the thread (just for printing/debugging)
- void terminate_thread()
- Can only be called by a thread to terminate itself (destroy the thread control block)
- void sleep(int ms)
- Thread is suspended for the specified amount of milliseconds
- int tick_count()
- Returns the number of milliseconds since the start of the system
Estimate for all functions of your operating system the worst case execution times. Is your operating system predictable? Also specify the time required for a context switch.
Think of an example to demonstrate your operating system. Your demo application should have at least two parallel activities. For your demo application, please indicate the utilization of the threads. Also specify deadlines, periods and execution times of the parallel activities.
As a starting point you can use an adapted version of the Lego NXT firmware (lab3.tar.gz). This start-kit already contains the configuration of the timer interrupt, which is necessary to implement pre-emptive scheduling. You may also use the version of the dispatcher, which already includes the context switch (lab3_inclswitch.tar.gz).