Writing a POSIX-compatible kernel

I wanted to write a kernel for a while. I already have sufficient knowledge of C, and I was involved in the x86 assembler. You see, I wanted to write a POSIX-compatible kernel in C so that * NIX applications could potentially be ported to my OS, but I did not find many resources for the standard POSIX kernel functions. I found resources on file system structure, environment variables, etc. On the POSIX Open Group page .

Unfortunately, I did not find anything explaining what kernel calls and functions should have a POSIX compatible kernel (in other words, what internal structure should the kernel have to match POSIX). If anyone can find this information, please tell me.

+6
c operating-system kernel
source share
2 answers

POSIX does not define the internal structure of the kernel, the kernel interface for the user, or even libc. Indeed, even Windows has a POSIX compatible subsystem. Just make sure that the POSIX interfaces defined in your link work somehow. Please note, however, that POSIX does not require any specific functions in the kernel - you can implement things in the C library using, if possible, simpler kernel interfaces of your own design.

It so happened that many POSIX-compatible operating systems (BSD, Linux, etc.) have a fairly close relationship between many of these calls and the kernel level, but there are exceptions. For example, on Linux, the write() call is a direct syscall, calling the sys_write() function in the kernel. However, on Windows, write() is implemented in POSIX DLL support, which translates a file descriptor into an NT descriptor and calls NtWriteFile() for maintenance; it, in turn, calls the corresponding system call in ntoskrnl.exe . Thus, you have a lot of freedom in how to do something that complicates the situation :)

+11
source share

opengroup.org leaves syscalls core solutions for every implantation.
write (), for example, should look and behave as directed, but what it calls below is not defined. Many calls, such as write, read, lseek, can call any entry point that they want in the kernel.

So, no, in reality there is nothing that says that you should have a certain function name with a certain set of semantics available in the kernel. It just needs to be available in the C runtime library.

+4
source share

All Articles