My Kernel v0.1.0
Kernel functions and structures
Collaboration diagram for Kernel functions and structures:

Modules

 Console
 
 Devices
 Kernel Device/Driver API.
 
 Errors
 
 Executable file format
 
 Interrputs
 
 Arch - x86
 
 Kernel dynamic allocator
 
 Logger
 
 Memory Constants
 
 Memory Management Unit
 
 Networking
 
 Physical Memory Manager
 
 Scheduling
 Scheduler implementation.
 
 Semaphore
 Semaphore.
 
 Kernel Symbols
 
 Syscalls
 
 Filesystem
 
 Virtual Memory Manager
 

Data Structures

struct  spinlock
 Spinlock. More...
 

Macros

#define __SPINLOCK_INIT
 Default init value (unlocked)
 
#define __INIT_SPINLOCK(_lock)   _lock = __SPINLOCK_INIT
 Initialize a spinlock.
 
#define DECLARE_SPINLOCK(_lock)   spinlock_t _lock = SPINLOCK_INIT
 Declare a spinlock and initialize it.
 
#define locked_scope(_lock)
 Define a scope that is guarded by a spinlock. More...
 

Functions

static ALWAYS_INLINE spinlock_t__spinlock_acquire (spinlock_t *lock, vaddr_t owner)
 Try to acquire a spinlock, or wait until it is free.
 
static ALWAYS_INLINE void spinlock_release (spinlock_t *lock)
 Release a spinlock for others to take it.
 

Detailed Description

Kernel

This is a kernel (not micro nor monolithic yet), written from scratch on my free time to learn more about systems and OS designs.

Disclaimer

This kernel serves only one purpose: learning.

The implementations and design choices are likely to be ... questionable, but this is part of the process. There exists better sources of inspiration and better examples than this project.

Structure

I try to keep arcihtecture specific code and what can be generic separated. You can find the architecture depedent code (specific structures, devices, mechanisms ...) inside the kernel/arch folder.

Macro Definition Documentation

◆ locked_scope

#define locked_scope (   _lock)
Value:
for (scope_lock_t guard CLEANUP(scope_lock_destructor) = \
scope_lock_constructor(_lock); \
!guard.done; guard.done = true)

This is particularily useful when taking and releasing a lock in a sequential manner. For example:

locked_scope(&list_lock) { llist_add(&global_list, &new_item); }

In this example the list_lock spinlock will automatically be taken when entering the scope, and also automatically released when leaving.

WARNING: As this macro uses a for loop to function, any 'break' directive placed inside it will break out of the guarded scope instead of that of its containing loop.