Search code examples
operating-systemosdev

Can you make an operating system which would support programs written for another operating system


If you were to make your own operating system, and make the syscalls "the same" as those of another operating system, would you be able to run programs made for that operating system natively? If not, what else would you need to "clone" to make it work? By having the same syscalls I don't mean just copy pasting code, rather having the same syscall codes, and having them have the same effect, just maybe getting to that effect differently.


Solution

  • Of course. FreeBSD kernel has binary interface for Linux system calls, and a loader for Linux binaries - so many Linux programs can run natively. WINE is a project, that allows to run Widows programs on Linux - because Windows does not expose its system calls directly (using library wrappers is mandatory for Windows programs), the compatibility layer can be done entirely in userspace.

    However, as you said, there is more to it than just system calls and a loader. Programs may depend on some files being present in the filesystem. For example, Linux uses virtual directories /proc and /sys to access some kernel features. If a system wants to mimic Linux - it should either have or emulate those directories. FreeBSD, for example, does not - Linux programs that use those files would not work correctly on FreeBSD.

    In general, for full compatibility you have to mimic the system very closely - even down to the bugs.