| ▲ | vintagedave 5 hours ago | ||||||||||||||||
So this seems to be a mystery binary someone found on a company DVD, that runs DOS on one core and runs another core with code but no interrupts etc. Fascinating. The thread later mentions a second way to do it. In this setup, how would cross-core communication work, including cross-thread? On DOS is there even the concept of threads, or would an app using this have to invent user-mode thread objects and scheduling? | |||||||||||||||||
| ▲ | toast0 4 hours ago | parent | next [-] | ||||||||||||||||
> In this setup, how would cross-core communication work, including cross-thread? Communication via shared memory. DOS and friends run on core 0 more or less normally; core 1 runs your alternate programming. Allocate a shared ring buffer for messages in each direction, core 0 writes messages and updates the written index on one, reads messages and updates the read index on the other; vice version for core 1. Core 1 probably spins on checking the indexes if it doesn't have anything else to do. Either allocate a big chunk of memory for core 1 work at startup, or let it message core 0 to allocate. Don't let core 1 call into DOS/BIOS syscalls directly or you'll have a big mess. Next step in efficiency would be letting core 1 sleep when it's bored and use an inter-processor interrupt (IPI) to wake it up as needed. | |||||||||||||||||
| |||||||||||||||||
| ▲ | fredoralive 5 hours ago | parent | prev | next [-] | ||||||||||||||||
DOS barely has any concept of processes, let alone threads. So it’ll all be very do it yourself. Of course with everything running in ring 0, there’s not much that’s going to get in the way of you. | |||||||||||||||||
| |||||||||||||||||
| ▲ | kmeisthax 4 hours ago | parent | prev [-] | ||||||||||||||||
DOS has no concept of multiple cores, much less threads. Multiprocessing in such an environment "works" mainly for the same reason why pthreads and friends "worked" in the decades before C++11 standardized a memory model for native code. The hardware and your code must conspire to work around the part that isn't thread-aware. Nothing is really stopping you from using the underlying hardware for concurrent execution, but at the same time DOS (and possibly BIOS/UEFI???) will blow chunks if you don't carefully synchronize access to it. Cross-core communication works exactly the same as it does in kernel-mode systems programming; and you need to bring your own synchronization primitives on top of the ones x86 processors ship with. You're basically writing an OS kernel at that point; one that just so happens to support kexec-ing back into COMMAND.COM and using bits of it as a filesystem driver. | |||||||||||||||||