Introduction

NSWI200: Operating Systems

Vojtěch Horký (horky@d3s.mff.cuni.cz)
Viktor Fuglík (viktor.fuglik@matfyz.cuni.cz)
Jan Papesch (JanPapuch@seznam.cz)

NSWI200: Operating Systems

Communication & co.

Milestones

M00: C language refresher

Tests

M01: Introduction to Kernel

M01 Inconveniences Fun

M02 and onward: work in teams

Unsolicited advice

M02: Heap

M03: Threads and Cooperative Scheduler

M04: Preemptive scheduler

M05: Virtual Memory Support

M06: Userspace Support

Grading

Grading

To pass the course …

… complete all milestones before mid January (baseline tests must work).

For a better grade

Details on course website

Lab plan

Questions?

@JP

M00 in detail

M00

Custom printing function

my_printf(const char* format, ...)

Print the format string, replacing % directives with actual arguments.

my_printf("The %s is %d.\n", "answer", 6*9 - 12); // The answer is 42

Supported directives:

No need to implement width, precision, length modifiers and other flags.

Extension:

Variadic arguments

static void print_strings(const char* header, ...) {
    puts(header);

    va_list args;
    va_start(args, header);
    const char *argument = va_arg(args, const char *);
    while (argument != NULL) {
        printf(" - '%s'\n", argument);
        argument = va_arg(args, const char *);
    }
    va_end(args);
}

...

print_arguments("Start of alphabet", "a", "b", "c", NULL);
print_arguments("No arguments", NULL);
print_arguments("Bad usage", "a", "b", NULL, "never printed", NULL);

Using linked lists

Why linked lists (and why these)?

Nothing more complex will be needed or required (this is OS course, not ADS).

Our lists will have maximum of tens (or very low hundreds) of items.

Do not implement them yourself. Seriously.

Switch to more complex data structure only when:

And even then: think twice (and reuse the code from Linux or HelenOS, please).

Typical linked list

list_t list;
list_init(&list);

payload_t * payload = create_payload();
list_item_t * item = create_list_item();
item->data = payload;

list_append(&list, item);

Embedded kernel-style linked list

list_t list;
list_init(&list);

payload_t * payload = create_payload();
link_init(&payload->link);

list_append(&list, &payload->link);

End of lab checklist