Page 1 of 2

NodeOS - An event driven operating system for the web

Posted: Thu Apr 05, 2012 9:19 pm
by ACcurrent
The aim of node OS is to create an OS kernel that can compile a port SDL and run the v8 javascript engine used in chrome. Node OS will be written in C and will try to use fewer than 1500 lines of code in the kernel and drivers. Node OS will run on the x86 architecture and support the RTL8169 ethernet chip, a vga card and IDE drives. Node OS will achieve these aims on 6th november 2012. Drivers will be implemented outside the kernel. I will reuse uIP for an IP stack that will be independent of the kernel and line count. The kernel ought to be multiboot compliant however, the kernel will use a somewhat different design than that of the typical *nix.

Since yesterday I have created the memory manager which uses a simple block partitioning scheme and the GDT and IDT.

While 6th november 2012 may seem like a long time, I will be spending more time porting and re-implementing things like SDL and stupid file systems - (I might only implement FAT or something similar). Github will be up soon.

Was inspired by the 10 second server OS. lol~

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 1:19 am
by piranha
create an OS kernel that can compile a port SDL and run the v8 javascript engine used in chrome. Node OS will be written in C and will try to use fewer than 1500 lines of code in the kernel and drivers. Node OS will run on the x86 architecture and support the RTL8169 ethernet chip, a vga card and IDE drives. Node OS will achieve these aims on 6th november 2012.
Good luck with that less than 1500 lines thing. My ata driver code is already a quarter of that, and it barely supports anything outside of the basic read/write stuff. My filesystem code (for ext2) is already way above that...
While 6th november 2012 may seem like a long time
Any particular reason for this date? Seems pretty precise. Also, it doesn't seem like a long time, that seems like a very short amount of time.

You say "compile a port SDL". Does that mean you want to compile SDL on your OS too? Or only port it to your OS? What about the basics of the kernel design? Do you intend to support multitasking? Multi-users? Are you going to port other programs to it (bash, gcc)?

-JL

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 2:05 am
by bluemoon
When you talk about 1500 lines of C code, are you planing to pack thousand of statements into single line, it will be un-readable :shock:

For some statistic, my Makefile alone has 90 lines, that's already 6% of your target budget.
And my kernel which essentially has no feature at all:

Code: Select all

$ wc -l *
      90 Makefile
      36 boot.h
     107 bootstrap.nasm
     104 device_mgr.cpp
      35 device_mgr.h
      59 driver_mgr.cpp
      32 driver_mgr.h
      34 heap.c
      33 heap.h
     122 initrd.cpp
      27 initrd.h
      33 inline_asm.h
     244 interrupt.nasm
     145 kdebug.c
      18 kdebug.h
      35 kernel.h
      51 kernel.inc
      56 kernel.ld
      75 kernel_data.nasm
      98 kmain.cpp
     103 kmalloc.c
      21 kmalloc.h
      64 mm_logical.c
      26 mm_logical.h
     156 mm_physical.c
      34 mm_physical.h
      17 new.cpp
     173 process.c
      58 process.h
      38 processor.cpp
     111 processor.h
     106 ramdisk.c
      20 ramdisk.h
      26 ring.nasm
      14 run.sh
     190 scheduler.c
      46 scheduler.h
     142 scheduler.nasm
     154 service.c
      41 service.h
      35 spinlock.h
      54 storage_mgr.cpp
      23 storage_mgr.h
     314 tablefs.c
      20 tablefs.h
     134 vfs.c
      29 vfs.h
    3583 total
That excludes loadable drivers, newlib glue, and my own shared library.

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 2:42 am
by ACcurrent
Nope. Nothing would use the GPU. The purpose is not to showcase the latest trends and best algorythms but to create a platform which is simple.
Makefiles can be made smaller. I know its crazy to get 1500 lines but when I looked currently with the partition based memory management tool I only have 100 lines. I will be posting it soon on github so you guys can see but I do not see it as impossible.
Most likely the layout of the code would be
Ethernet driver - 10 lines
VGA - 100 lines (with double buffering)
GDT.c+IDT.c+DescriptorTables.s - 132 lines
Common.h - 20 lines
Memory.c - 124 lines
Syscalls.c - 65 lines
So there! The main challenge will now be thread.c.
Also note: I stated Kernel and driver code so makefiles will not be included.
The dates me bein' random 6th november... I wonder whats on then?

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 7:14 am
by Yoda
IMHO, more fairly will be to measure the size of OS not in C lines, but in non-compressed KiBs of compiled size of kernel, since you really may pack a lot of instructions into one source line.

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 7:38 am
by Combuster
Hypothesis:

Code: Select all

  output size
--------------- = % stupid programmer
   code size
:wink:

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 7:43 am
by bluemoon
Please, share your tricks to write ethernet driver in 10 line (or 10% of code to setup GDT/IDT).

I mean, I also want to write ethernet driver soon.
I would expect it in human readable form, and not sed -i 's/\n//g' *, even in the worst polling interface it would look like:

Code: Select all

int ethernet_send(...) {
  return E_OK;
}
int ethernet_recv(...) {
  return E_OK;
}
Oh that's 6 lines out of 10...please teach me the magic.

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 8:06 am
by Yoda
@bluemoon,
You may easily pack your 6 lines into just one :D

Code: Select all

int ethernet_send(...) { return E_OK; } int ethernet_recv(...) { return E_OK; }
And still there is a lot of space for another actions...

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 8:25 am
by bluemoon
No, no sed -i 's/\n//g' * :twisted:

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 10:25 am
by brain
bluemoon wrote:No, no sed -i 's/\n//g' * :twisted:
Maybe he didn't use sed, maybe he used perl -p -i -e 's/\n//g' Ethernet.c ;-)

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 11:03 am
by invalid
Sorry for extended OT, but bluemoon wrote:
bluemoon wrote:And my kernel which essentially has no feature at all:
(...)
3583 total
Are those numbers real? :shock: I believe my kernie is nowhere near yours, and wc shows:

Code: Select all

    202 boot_sector1.asm
    573 boot_stage2.asm
     60 common.h
    118 devices.c
     44 devices.h
    404 fdX.c
     23 fdX_irq.asm
     62 gdt.asm
     25 hades.c
     71 hdX.c
     18 hdX_irq.asm
     60 init.c
    552 interrupts.asm
     81 kernel.asm
     79 kernel_boot.asm
     45 keyboard.c
     20 keyboard.h
     15 keyboard_irq.asm
    744 mmgr.c
    176 mmgr.h
     35 panic.asm
    535 pci.asm
    165 print.c
     16 print.h
    133 sched.c
     46 sched.h
    383 sfs.c
     70 sfs.h
    375 shell.c
    334 stageinfo.c
     85 stageinfo.h
    106 tasks.asm
     66 tss.asm
    191 vfs.c
     84 vfs.h
    358 vga.c
     20 vga.h
  43 klib/mem.c
   8 klib/mem.h
 124 klib/string.c
  15 klib/string.h
Do you put comments in your code? =P~

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 11:13 am
by bluemoon
ydoom wrote:Do you put comments in your code? =P~
Well, indeed not much commented, since
1. I'm lazy (or busy, well)
2. code block are well broken down into few lines each, which would be overkill to comment all the source.
3. Some but not much specially optimized or tweaked or tricks are documented for maintainability
4. I'm in the middle of a major rewrite, but I'll add doxygen style comment to header files on interface descriptions once they are stable
5. I do have document on the overall design and object relationship diagrams, but they are not in the kernel source folder.

Yes. I'm aware and agree that comment, and documents are important.

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 1:47 pm
by piranha
Why even restrict yourself to a set number of lines? Thats not going to help you AT ALL. In ANY WAY. For ANY REASON.

I bet 100 internet kittens that few of your goals will play out as you have laid them out in your OP.

-JL

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 5:57 pm
by IanSeyler
This is exactly what my BareMetal Node project is all about. A very simple JeOS (Just enough Operating System) that is meant for running some other binary package that is sent to it.

I write in Assembly so lines of code don't mean too much.. however the total binary size is 8KiB.

Don't focus on lines of code. I've coded an RTL8169 driver and there is no reasonable way you could do it in "10 lines".

-Ian

Re: NodeOS - An event driven operating system for the web

Posted: Fri Apr 06, 2012 7:23 pm
by VolTeK
OT
ydoom wrote: Sorry for extended OT, but bluemoon wrote:

bluemoon wrote:
And my kernel which essentially has no feature at all:
(...)
3583 total


Are those numbers real? I believe my kernie is nowhere near yours, and wc shows:
Code:
    202 boot_sector1.asm
    573 boot_stage2.asm
     60 common.h
    118 devices.c
     44 devices.h
    404 fdX.c
     23 fdX_irq.asm
     62 gdt.asm
     25 hades.c
     71 hdX.c
     18 hdX_irq.asm
     60 init.c
    552 interrupts.asm
     81 kernel.asm
     79 kernel_boot.asm
     45 keyboard.c
     20 keyboard.h
     15 keyboard_irq.asm
    744 mmgr.c
    176 mmgr.h
     35 panic.asm
    535 pci.asm
    165 print.c
     16 print.h
    133 sched.c
     46 sched.h
    383 sfs.c
     70 sfs.h
    375 shell.c
    334 stageinfo.c
     85 stageinfo.h
    106 tasks.asm
     66 tss.asm
    191 vfs.c
     84 vfs.h
    358 vga.c
     20 vga.h
  43 klib/mem.c
   8 klib/mem.h
124 klib/string.c
  15 klib/string.h


Do you put comments in your code?


Id have to agree with many on here, size of projects in klocs may prove how much work was put into but, it doesn't prove that it can do much, or that its size makes it any better. Maybe makes it an even bigger pain to organize.

My kernel and drivers are nearing 11,000 lines (kernel 6233 lines, 2 drivers 4107 lines) and all it is right now is a multitasking real mode kernel with basic Memory management, Process management, and full FAT12/16 support (each manager as expected being well over 1500 lines).

It's only fairly bigger in size somewhat because its in assembler.