Whether i need my own library in OS ?




Whether i need my own library in OS ?

Postby MasterCna » 7. Mar 2017, 15:29

I tried to write a quite well and clean OS. In the end of writing codes and release version 1.0, do i need to write any library for that ? like Windows API . :geek:
I want to developers feel free to write applications for my OS.
User avatar
MasterCna
 
Posts: 11
Joined: 7. Mar 2017, 00:17

by Advertising » 7. Mar 2017, 15:29

Advertising
 

Re: Whether i need my own library in OS ?

Postby algorithman » 8. Mar 2017, 10:06

well if you support all the usual stuff (open/close files, write to stdout, read from stdin etc.) via syscalls, then your users can just use syscalls, but it would be nice for them if you give them a library that provides a nicer API to the syscalls. Something like
Code: Select all
int fopen(char* filename, int flags, int mode)
{
    int filedescriptor;
    asm("int $0x80" : "=a"(filedescriptor) : "a"(5), "b"(filename), "c"(flags), "d"(mode));
    return filedescriptor;
}
...


Then the users can statically link to that library and call fopen etc. as they are used to.
When they compile their programs, they need to turn off exceptions, disable linking dynamically against the usual libraries (glibc, glibc++ etc.) and statically link against your library instead.

Don't forget: you still need some way to start the programs. Reading something from the hard drive and attaching a function pointer to your processes list is discussed in the tutorials, but after reading the executable binary into ram, which function pointer do you attach to the processes? I would suggest that you implement the ELF file format, so that your users can just use gcc to compile (if you make up your own format, then you need to give your users a cross compiler).
User avatar
algorithman
Administrator
 
Posts: 49
Joined: 2. Mar 2017, 11:40


Return to General Discussion

Who is online

No registered users

cron