Giter VIP home page Giter VIP logo

sos's Introduction

logo

sos

Sian's experimenting Operating System written in C++. it's a 32bit os kernel and runs on uniprocessor.

screenshot

BUILD

Like makefile indicated, this is a x86 kernel, and you need a i686 gcc cross compiler for building and running it. see here for the information. I think it also works under a 32bit GNU/Linux distribution. you may need to specify -Wl,--build-id=none for successful compiling. The kernel follows multiboot protocol and need a hd img with grub2 preinstalled. Here is a premade image for testing.

Refs

xv6 is a great reference implementation of a unix style kernel. linux 0.11 is also worth reading, and I learned a lot from these projects. You can find a lot of info about writing an small os kernel here.

Notes

One of the hardest as far as I can tell is memory management. I do implement my own kmalloc/kfree based on a simple algorithm. The way I choose to manage memory (both physical and virtual) makes some thing hard to implement, i.e shared memory region.

Another thing is task switch. There are many ways to do this, xv6's way or old linux way or your own method.

When design other parts of the kernel, you can stick to the unix tradition or just go bold and invent your own.

How to make a hd.img

This works under modern GNU/Linux (tested on Deepin 15). make disk image, then use parted (or fdisk to format as msdos)

dd if=/dev/zero of=hd.img bs=1M count=500
sudo parted hd.img mklabel msdos
sudo parted hd.img mkpart primary fat32 0% 100%

bind loop device (fat32 partition will be /dev/loop0p1) and mkfs

sudo losetup -f -P -v hd.img
sudo mkfs.vfat -F 32 /dev/loop0p1

then mount fat32 partition and install grub2:

sudo mount /dev/loop0p1 /mnt
sudo grub-install --modules="fat biosdisk normal part_msdos ext2 multiboot" --root-directory=/mnt /dev/loop0

TODOs

  • tty and io partially works
  • enough syscalls for sh
  • write support of vfs & block io layers
  • signal handling (partially)
  • simple GUI and software renderer (may port mesa if possible)
  • port newlib as userland libc

ISSUSE

  • physical mm is not good enough, and it's impossible to do va->pa & pa->va convertion.
  • userspace alloc will make some virtual address in kernel space can not be mapped (by adding KERNEL_VIRTUAL_BASE). which in turn may cause kernel has no mem to alloc.
  • sos use trap gate for syscalls, which leaves IF as it was(not cleared). must be very careful.
  • spinlock can not used in irq context in uniprocess system.
  • take care of the IF state, sleep can only happen with IF enabled context and wakeup from irq context leave IF disabled.
  • about spinlock: busy-waiting isn't enough when access syscall is a trap gate (IF enabled). we need to make sure cli'ed so fork / exec will not be preempted before finished.

sos's People

Contributors

sonald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sos's Issues

关于文件头部作者及版权的添加

大神,发现你的所有代码都没有文件头部注释,个人感觉还是有必要在每个文件头部添加作者信息,修改时间以及版权,虽然大神你可能不屑于这些,但是万一谁有个什么问题的,也知道向谁求助吧。
(你说对了,我没编译通过,你竟然也用qemu做测试,看来这个确实是好东西)。
你的简历http://sonald.me/Resume/ 的github链接地址不对(中英文都是哦)。

我又来*扰了,这次是关于网络的

大神,看你前些天又有更新了,这个是个长期的爱好。我这半年查看了一些关于操作系统的知识,发现一个小的,被用的操作系统xinu,xinu不是玩具,已经被工业上使用,也不大,相比xv6,它更具有意义。因为它被用,它的精华在网络部分,有本书专门介绍这个系统的细节(书老版本是介绍mips的,最新的版本是介绍x86和arm的),写书的人也是个网络方面的牛人。我觉得以后如果这个一直做下去的话,可以借鉴xinu的网络部分。我一直的观点是,在现在,有了网络,系统才算真正的活了。我喜欢网络,奈何我水平有限啊,只能仰望你们这些大神。希望我提供的这点信息对你能有帮助。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.