Recent submissions

Comment · 1 year ago
Thanks for taking the extra time making me consider dropping the term "kernel". But I need a term wich reflects my efforts. So I fed your description at the end into ChatGPT, asking for a one-word description. This is what it came up with:

Paravirtualized – commonly used when an interface mimics low-level system behavior but redirects to a host implementation; this fits your syscall-level emulation.

Interposed – describes the interception and redirection of system calls or API behavior.

Emulated – broad but accurate; emphasizes imitation of behavior at the syscall layer.

Rehosted – suggests the POSIX environment has been adapted to a different host OS.

Substituted – captures the idea of replacing one system mechanism with another.

Intercepted – emphasizes the capture and redirection of syscalls.

Translated – suitable if there's transformation between POSIX calls and Windows kernel APIs.

Adapted – highlights compatibility through minimal changes.

Bridged – suggests a connection or interface between incompatible systems.

Virtualized – somewhat general, but appropriate if the environment feels like a lightweight VM layer.

Interesting, but not very creative. Something like Ted Nelson's "transclusion". Suggestions? Anyone?

Comment · 1 year ago
OpenBSD has pkg_add and friends. Which I can't release yet. They need Perl which I can't release yet either. Although stable already, there still is one vital thing I need implemented in MinC.
Comment · 1 year ago
Comment · 1 year ago
My choice for this particular IRC client (not naming it) came from the Mr.Robot series (S04E04 at 59:38:00). I am teaching 16 year olds. They like that kind of thing.
Comment · 1 year ago
Thanks for taking the time to read the source code and commenting on it. And you're right. My kernel is implemented in userspace, so I should use the term "kernel emulation". But I did find it fascinating to find out some of the reasons why a kernel is needed in the first place.

For starters, I needed to put the code of my kernel emulation (libposix-6.1.0.dll) at a specific memory address in order to get that snappy feeling when you start an OpenBSD program. Normally, 32bit DLLs in Windows are loaded at 0x10000000 (called the "ImageBase"). This causes the Windows kernel reposition the DLL because in most cases, other DLLs are already loaded there. In my case these are netapi32.dll, ws2_32.dll, iphlpapi.dll and shell32.dll among others. Making my DLLs load at an address just below the 0x10000000 boundary makes MinC programs load faster, in effect creating a space for my kernel, e.g. "kernel space".

Secondly, I needed some mechanism to reset the contents of the CPU's registers after calling into the various Windows DLLs which are not part of the Windows NT kernel. For instance, the WriteFile() function changes the %edx register, which is used by the GCC compiler to contain the high part of 64bit variables. Turns out I needed what is called a "context switch", saving the contents of all registers onto the stack, calling my kernel emulation and then restoring the registers from the stack. In Linux, this mechanism is triggered by a special interrupt (int 0x80). I decided to name the function that does this in my kernel emulation "__kernel", so in assembly I can write "call ___kernel" [0].

There is more, but I won't go into that right now. I plan to do a write-up on the topic. By the way, Microsoft also has a user space implementation of their kernel, called kernel32.dll, implementing Win32 APIs in user space.

[0] https://github.com/dboland/minc/blob/master/libposix/arch/x8...

Comment · 1 year ago
Comment · 1 year ago
> I've to say that you've clearly thought a lot about this, and though I've not tried it (and probably won't) you seem to have done an excellent job.

Thank you. I needed that. I started the project in 2016 and have been obsessed with it since then. The weird thing is that I never had to use workarounds or hacks that are mentioned by the Cygwin team [0]. For instance, the select() call does map cleanly on top of the Win32 API. I just needed to use WSAWaitForMultipleEvents() instead of WaitForMultipleEvents() (the other "easteregg"). Why the Cygwin people didn't figure this out baffles me. I guess their current code base doesn't allow the rewrite. My big breakthrough was when I realized that the "inconsistent interfaces" [1] in Win32 file handles can be implemented as virtual file systems. One for each handle type (char, disk, pipe, etc). That was my "throwing away 1000 lines of code" [2] moment.

As to the weird file names, I use the file names OpenBSD uses. My rule is to always use the file name of the header (.h) file where the system call is declared in OpenBSD. I also use their struct and constant names, prefixed with "WIN_".

The "fork is evil" thing is discussed a lot in the programmers community. I myself find it quite clever. Threads are highly volatile and are very hard to program without running into race conditions. The solution is to make a copy of everything the child will be using: duplicate file descriptors, the stack, globals (rss). The kernel does all this for you in one system call. I often wonder how the people who complain about the absence of real concurrency in their programming languages [3] actually would use this feature. In my opinion the best way to use concurrency is to string individual programs into a pipeline. This will never go "evil" on you.

[0] https://cygwin.com/cygwin-ug-net/highlights.html

[1] https://www.usenix.org/legacy/publications/library/proceedin...

[2] https://skeptics.stackexchange.com/questions/43800/did-the-c...

[3] https://news.ycombinator.com/item?id=32408577

Comment · 1 year ago
Cool. You found out why MinC is not Cygwin. To fork(), Cygwin starts a second copy of the entire executable. CreateThread() is much closer to what UNIX does. Any thoughts? BTW, there's another "easteregg".
Comment · 1 year ago
Comment · 1 year ago
I understand your point, but I'm intrigued. Could you elaborate with some kind of example why it is disappointing that people don't date their web-pages? Is this a generic problem or is it with specific web-sites only?
Comment · 1 year ago
Ah! You got it. Are you a teacher? You should try it.
Comment · 1 year ago
I don't mind. Many of the comments are about my incorrect use of the term Linux. In a way, they are right. But if one wants to teach Automotive Technology to future BMW mechanics, you start them working on a VW Beetle. Wax on wax off.
Comment · 1 year ago
It works now. I had to add -pix_fmt yuv420p to my ffmpeg parameters. Thanks for the comments on this.
Comment · 1 year ago
Yes.
Comment · 1 year ago
You hit an important point here. Teaching IT to 16 jear old children is very much like being an admin for a large corporation. Most of them have installed VMWare, VirtualBox, Hyper-V and pfSense, depending on the preference of the other teachers. Most first-graders don't know anything about networking, so I didn't want to add WSL to that. I used Cygwin. Worked perfectly until I started to teach Sendmail. Sendmail runs in unprivileged mode. This means that it starts as root, but then switches to a user with very few rights. Cygwin couldn't handle that at first, but I got it working. But then students couldn't uninstall Cygwin anymore because of changed file ownership in Windows. I had to install a second Cygwin to uninstall the first. With MinC I took extreme care to get all the different models of Access Control Lists that are used in Windows right.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton