5 ms·
Used to be a staff member working on an x86 OS called CTOS. I realized if I implemented a couple of traps, we could run command-line DOS programs. So I did. And
by JoeAltmaier 5mo ago
Used to be a staff member working on an x86 OS called CTOS. I realized if I implemented a couple of traps, we could run command-line DOS programs. So I did. And it worked. Dev tools, text processing, piped commands all worked.
It helped that the DOS executable format was the same as the CTOS format - because we had traded Bill Gates our linker (which produces executables) for his BASIC compiler.
- CyberDildonics 5mo agoif I implemented a couple of traps What does this mean? System calls?
- jjk7 5mo agoBefore SYSCALL there was INT
- m463 5mo agoI remember SVC. and also things like BR14 and IEFBR14
- hack1312 5mo ago[dead]
- rtkwe 5mo agoSimilar but traps are triggered automatically on attempts to execute a protected instruction. https://www.geeksforgeeks.org/operating-systems/traps-and-system-calls-in-operating-system-os/ https://www.geeksforgeeks.org/operating-systems/traps-and-sy...
- dullcrisp 5mo agoWhy/when are traps used rather than explicit system calls? Is it just historical coevolution? Or is the idea that the user mode program doesn’t need to know that it’s unprivileged? Or is it just repurposing the error handler path to perform privileged operations?
- Polizeiposaune 5mo agoDepends on the processor architecture and its nomenclature. Traps typically also result from exceptional conditions (like divide by zero or page fault). An architecture may or may not provide non-trap paths for less-privileged code to invoke more-privileged subsystems (call gates, "syscall" instructions, etc.). Traps typically need some way to preserve all userspace-accessible registers (otherwise resuming from a page fault is .. hard). Dedicated syscall instructions may only need to restore a subset of registers. In some implementations, processors may discover that an instruction must trap after it starts irreversibly changing architecturally-visibile state; in cases like that, the processor needs to leave enough breadcrumbs for the OS to allow either a clean unwind or a resumption of the interrupted instruction. My understanding is that the original 68000 somewhat famously got this wrong.
- bonzini 5mo agoAt the time of DOS, x86 didn't have multiple privileges. The system call instruction was typically INT, the software interrupt instruction. Later on the 386 Intel added virtual 8086 mode which trapped to the kernel privileged instruction exception also for certain instructions that had to be virtualized, among them INT.
- JoeAltmaier 5mo agoYes, exactly. We used a set of INT instructions in well-known low memory addresses that all jumped to the same place. We had an ASM file that you linked with, that had sixteen different address combinations for each. The common entry point would look back on the stack and calculate from the return address which entry point had been called, and run the appropriate kernel call. We called it the CS:IP hack. In the context of this post, the DOS INT10 and INTx(I forget) required the caller to load registers with the desired system call number, then perform the trap instruction in their code. Fortunately CTOS didn't need those particular software interrupts, so I could implement them for my purposes.
- globalnode 5mo agoint 21h !
- rolph 5mo agoif you know a particular process or system callmakes errors,then you run code that checks for that error,or exception,or preempively hooks a problematic system call,to redirect to "your"code that handles the state of exception,and returns. https://en.wikipedia.org/wiki/Interrupt#Terminology https://en.wikipedia.org/wiki/Interrupt#Terminology
- fintler 5mo agoNeed to pee? Take the a-trap to Shell.
- therealfigtree 5mo agoIt's a trap
- __patchbit__ 5mo agoThe F-14 Tomcat had an early period microprocessor and landing on an aircraft carrier would have the tailhook snag arresting wires in a trap. But the trap idea precedes the Tomcat by a decade in computing according to the AI.
- actionfromafar 5mo agoThat's a great twist! Very few people traded Bill Gates a linker for a compiler!
- jr_isidore 5mo agoYes, I agree. Amazing twist of fate.
- hnthrowaway0315 5mo agoLooks like this one? https://en.wikipedia.org/wiki/Convergent_Technologies_Operating_System https://en.wikipedia.org/wiki/Convergent_Technologies_Operat... Thanks for sharing, never heard about it before. What was kernel programming back then? Briefly checked the wikipedia and looks like CTOS was kinda big in the government space back in the 80s.
- JoeAltmaier 5mo agoIt was popular with govt because it came with an HDLC network build-in, server/client depended on the OS you booted. This saved you a network administrator. The kernel was in Intel ASM86 but the rest of the OS was written in PLM86. When I joined it was 2MB of code on a 128K 8086 cpu. By the time I left it was 9MB of code running on an 80386.
- hnthrowaway0315 5mo agoThanks Joe. Interesting knowledge. I managed to find a FAQ and was surprised that it made to the year 1999. https://web.archive.org/web/20110708212436/http://www.ctosfaq.com/CtosFaqOct1999.htm https://web.archive.org/web/20110708212436/http://www.ctosfa...
- throw98226 5mo agoIf you wanted to get into development mode in CTOS, the keyword was 'developement' - an e between the p and the m. Worked on this system back in early 1990 as a developer.
- dullcrisp 5mo agodevelopéer
- KolibriFly 5mo agoThis is such a neat historical parallel
- CTOSian 5mo agohello! hello! I was mainly admin and COBOL dev with them (I wish I kept the collection of the manuals and PRGs, alas when no space..), bitsavers have a quite collection (incl a virtualbox HDD) if you are interested!