Skip to content

Latest commit

 

History

History
167 lines (116 loc) · 3.89 KB

README.md

File metadata and controls

167 lines (116 loc) · 3.89 KB

DeliciOS

[中文]

DeliciOS (homonym "delicious") is a simple 64-bit Operating System kernel written by C11.

Its Bootloader uses GRUB, and it already has some basic kernel features:

  • Process Management
  • Memory Management
  • System call (soft interrupt)
  • Keyboard input
  • Text output (console)

Following the principle of "just for fun", I think it also needs the following features:

  • SMP
  • File System (maybe VFS)
  • Socket (TCP)

Building DeliciOS

Docker (development environment)

Run following command to compile and run DeliciOS in docker

docker run --name delicios --rm -it -v $PWD:/code joverzhang/delicios-env:0.1

Stop DeliciOS container (because it can't shutdown by itself)

docker rm -f delicios-env

Compile

DeliciOS can be compiled on 64-bit Linux or MacOS.

Run following command to build the kernel.iso.

make

or

make x86_64.iso

When the kernel.iso has been built. Use following command to run Qemu.

qemu-system-x86_64 ./dist/release/x86_64/kernel.iso

Then you can see:

welcome_to_deliciOS.png

Playing

Boot DeliciOS

boot.gif

Run the Multiprocess Program

code:

// the mock user program it's written like the program on Linux.
//
// following is an example of a multiprocess program.
// ps: the "fork()" is a "system call" of create a child process in kernel.
static noreturn void mock_user_program() {
  if (!fork()) {
    if (!fork()) {
      if (!fork()) {
        while (1) {
          console_set_foreground_color(CONSOLE_LIGHT_GREEN);
          printf("[p4]: print d\n");
          msleep(250);
        }
      }
      while (1) {
        console_set_foreground_color(CONSOLE_LIGHT_GRAY);
        printf("[p3]: print c\n");
        msleep(500);
      }
    }
    while (1) {
      console_set_foreground_color(CONSOLE_LIGHT_BLUE);
      printf("[p2]: print b\n");
      msleep(750);
    }
  }
  while (1) {
    console_set_foreground_color(CONSOLE_LIGHT_RED);
    printf("[p1]: print a\n");
    msleep(1000);
  }
}

console output:

multiprocess_screen.png

Exception Handler

code:

printk("started kernel\n");
// division by zero
i32 a = 10 / (get_cs() >> 30);

console output:

division_by_zero_screen.png

Contributing

Contributions are welcome and encouraged, provided your code is of sufficient quality.

Issues:

High Priority

  • [Process] Implement process switching based on kernel stack switching. Now, process switching is similar to used TSS. sched.c
  • [Memory] A "General Protection" exception will appear if the DPL of the CS (code segment) and DS (data segment) in user space settings to 3. (The current DPL settings to 0) gdt.c
  • [Memory] Implement paging algorithm on page fault. Now, the virtual address is equal to the physical address. page.c

Low Priority

  • [Console] Use the daemon process to control the console.
  • [Chore] Change the x86 assembly to AT&T and remove NASM.

Future

I hope it can support earlier versions of Shell and GCC. (like a modern Linux 0.01)

And in the end, We will refactor it. Write all core code in the stupidest (simplest) way.

I hope to help some lost person who loves the operating system (such as me).

Acknowledgement

no rank

License

DeliciOS is under the GPLv2 License. See the LICENSE file for details.