YAROS is a small project of mine that I did during class for fun It’s my first attempt to make an OS kernel.
YAROS is release on GPL 3.0 by default, see LICENSE. However, I can give you copyright for other licenses such as LGPL. Please contact me privately on this matter.
YAROS as now its own manual.
You can read the manual of YAROS on GitHub here, or you can download in differents format here. You can also compile the manual yourself in info, html or pdf, dvi, ps, formats.
To compile the manual, use make format. This will compile the manual under build/format/YAROS.format, where format is the file format that you want.
For example:
make pdf will compile the manual under build/pdf/YAROS.pdf.
but
make info will compile the manual under build/info/YAROS.info.
YAROS use AVR Libc and was designed to be used with GCC. Other compilers will not be supported.
#include "init/init.h"
#include "kernel/task.h"
#include "kernel/sysclk.h"
#include "devices/usart.h"
/* foo has priority level 0, nice value of 5 and a stack of 50 bytes */
struct task foo = TASK(TASK_P0, TASK_N5, 50);
/* foo has priority level 4, nice value of 9 and a stack of 75 bytess */
struct task bar = TASK(TASK_P4, TASK_N9, 75);
OS_TASK void
do_foo(void *task);
OS_TASK void
do_bar(void *nil);
int
main(int argc, char *argv[])
{
/* Initialize the Kernel */
init_kernel();
/* Foo is scheduled */
run_task(&foo,
do_foo,
&bar);
/* Bar is suspended */
init_task(&bar,
do_bar,
NULL);
run_kernel();
}
OS_TASK void
do_foo(void *bar_task)
{
static const char foo_str[] = {'f', 'o', 'o', '\n'};
while (1) {
/* Write "foo_str\n" to USART 0 */
write_usart(0, foo_str, sizeof(foo_str));
/* Resume bar */
resume_task(&bar);
/* Wait 1 second */
wait(HZ);
/* Suspend bar */
suspend_task(&bar);
}
}
OS_TASK void
do_bar(void *nil)
{
static const char bar_str[] = {'b', 'a', 'r', '\n'};
while (1) {
/* Write "bar\n" to USART 0 */
write_usart(0, bar_str, sizeof(bar_str));
/* Wait 1/2 second */
wait(HZ / 2);
}
}
Loaded 6770 .text at address 0x0
Loaded 244 .data
avr_gdb_init listening on port 1234
gdb_network_handler connection opened
gdb_network_handler recv: Connection reset by peer
gdb_network_handler connection closed
gdb_network_handler connection opened
foo.
bar.
bar.
foo.
bar.
bar.
foo.
bar.
bar.
foo.
bar.
GDB hit control-c