Earlier quoted context omitted.
Bliss 36 and siblings had native coroutines. We used coroutines in our interrupt rich environment in our real time medical application way back when. This was all in assembly language and the coroutines vastly reduced our multithreading errors to effectively zero. This is one place where C , claimed to be close to the machine falls down.
interesting, i didn't even realize bliss for the pdp-10 was called bliss-36 how did coroutines reduce your multithreading errors
Niklaus Wirth has died
361–370 of 412 posts
Re: Niklaus Wirth has died
#362Earlier quoted context omitted.
Are you familiar with the 'Leo' editor? It is the one that comes closest to what I consider to be a practically useful literate programming environment. If you haven't looked at it yet I'd love it if you could give it a spin and let me know what you make of it. https://leo-editor.github.io/leo-editor/
i read a little about it many years ago but have never tried it. right now, for all its flaws, jupyter is the closest approximation to the literate-programming ideal i've found
Re: Niklaus Wirth has died
#363Earlier quoted context omitted.
Sure, that's a good way to look at it. Another way to look at it: because the process of transforming code for cooperative multitasking is now much cleaner and simpler, it's fine to use new words to describe what to do and how to do it.
cooperative multitasking, as i use the term, keeps you from having to transform your code. it maintains a separate stack per task, just like preemptive multitasking. so async/await isn't cooperative multitasking, though it can achieve similar goals possibly you are using the terms in subtly different ways so it appears that we disagree when we do not
If the OS forcefully switches control it's preemptive.
Re: Niklaus Wirth has died
#364Earlier quoted context omitted.
interesting, i didn't even realize bliss for the pdp-10 was called bliss-36 how did coroutines reduce your multithreading errors
I’m working up a blog post and will let you know when it is ready. Not at my desk just now
Re: Niklaus Wirth has died
#365Earlier quoted context omitted.
I had wanted to interview Val Schorre [1], and looked him up on a business trip because I was close. Died 2017, seems like a righteous dude. https://www.legacy.com/us/obituaries/venturacountystar/name/... [1] https://en.wikipedia.org/wiki/META_II
yeah, i wish i had had the pleasure of meeting him. i reimplemented meta-ii 3½ years ago and would recommend it to anyone who is interested in the parsing problem. it's the most powerful non-turing-complete 'programming language' i've ever used http://www.canonical.org/~kragen/sw/dev3/meta5ixrun.py (i mean i would recommend reimplementing it, not using my reimplementation; it takes a few hours or days) after i wrote…
'.SYNTAX' .ID .OUT('ADR' *) ...
but I'm having trouble understanding what the ADR code is supposed to do. By my understanding, that line should instead read something like '.SYNTAX' .ID .OUT('CLL *') .OUT('HLT') ...
where HLT is some code that causes the machine to halt, or possibly '.SYNTAX' .ID .OUT('B *') ...
using the otherwise-unused unconditional branch code, and then defining R on an empty call stack as a machine halt.Re: Niklaus Wirth has died
#366Earlier quoted context omitted.
cooperative multitasking, as i use the term, keeps you from having to transform your code. it maintains a separate stack per task, just like preemptive multitasking. so async/await isn't cooperative multitasking, though it can achieve similar goals possibly you are using the terms in subtly different ways so it appears that we disagree when we do not
Cooperative multitasking is "The illusion of simultaneously executing code paths by having said code paths pass control to each other fast enough." If the OS forcefully switches control it's preemptive.
in the mac os 8 documentation, explaining how mac os 8 only has 'cooperative multitasking', the term is defined in the way i'm using it (https://developer.apple.com/library/archive/documentation/Ca...):
> In programming, a task is simply an independent execution path. On a computer, the system software can handle multiple tasks, which may be applications or even smaller units of execution. For example, the system may execute multiple applications, and each application may have independently executing tasks within it. Each such task has its own stack and register set.
> Multitasking may be either cooperative or preemptive. Cooperative multitasking requires that each task voluntarily give up control so that other tasks can execute. (...)
> The Mac OS 8 operating system implements cooperative multitasking between applications. The Process Manager can keep track of the actions of several applications. However, each application must voluntarily yield its processor time in order for another application to gain it. An application does so by calling WaitNextEvent, which cedes control of the processor until an event occurs that requires the application’s attention.
that is, this requirement that each task have its own stack is not just something i made up; it's been part of common usage for decades, at least in some communities. the particular relevant distinction here is that, because each task has its own stack (or equivalent in something like scheme), multitasking doesn't require restructuring your code, because calling a normal function can yield the cpu. in the specific case of macos this was necessary so that switcher/multifinder/process-manager could multitask mac apps written for previous versions of macos that didn't have multitasking
what term would you propose for what i'm calling 'cooperative multitasking', like forth and mac os 8 and windows 3.1 (https://softwareengineering.stackexchange.com/questions/3507... https://retrocomputing.stackexchange.com/questions/791/how-d...)? this terminology is not absolutely standardized, and i'd be happy to use different terminology in order to be able to communicate productively
also could you please answer my request for clarification in https://news.ycombinator.com/item?id=38861074
Re: Niklaus Wirth has died
#367Earlier quoted context omitted.
interesting, i would have said the relationship is the other way around: cooperative multitasking implies that you have separate stacks that you're switching between, and coroutines are a more general idea which includes cooperative multitasking (as in lua) and things that aren't cooperative multitasking (as in rust and python) because the program's execution state isn't divided into distinct tasks i could just be wr…
Yeah thinking about it more I didn’t intend to imply a subset relationship. Coroutines are not only used to implement cooperative multitasking, for sure.
lua's coroutines aren't automatically scheduled (there isn't a built-in run queue) but explicitly resumed, which is a difference from the usual cooperative-multitasking systems; arguably on that basis you could claim that they aren't quite 'cooperative multitasking' on their own
the last time i implemented a simple round-robin scheduler for cooperative multitasking was in july, as an exercise, and it was in arm assembly language rather than lua. it was 32 machine instructions and 64 lines of code (http://canonical.org/~kragen/sw/dev3/monokokko.S), plus 14 lines of example code to run in the threads. when i went to go look at that just now i was hoping to come up with some kind of crisp statement about the relative importance or complexity of the stack-switching functionality and the run-queue maintenance facility, but in fact there isn't a clear separation between them, and that version of the code creates all the tasks at assembly time instead of runtime. a more flexible version with start, spawn, yield, and exit calls, which respects the eabi so you can write your task code in c (http://canonical.org/~kragen/sw/dev3/einkornix.h et seq.), is 53 lines of assembly and 34 machine instructions, but similarly has no real separation of the two concerns
Re: Niklaus Wirth has died
#368Pascal was the first programming language I ever learned, and a book on it that he coauthored was the first programming book I ever purchased. I hold him (and Pascal) in a special place in my heart.
Re: Niklaus Wirth has died
#369Earlier quoted context omitted.
Cooperative multitasking is "The illusion of simultaneously executing code paths by having said code paths pass control to each other fast enough." If the OS forcefully switches control it's preemptive.
that definition is different from the definition i'm using; it covers both what i'm calling 'cooperative multitasking' and things like async/await, the npm event handler model, and python/clu iterators in the mac os 8 documentation, explaining how mac os 8 only has 'cooperative multitasking', the term is defined in the way i'm using it ( https://developer.apple.com/library/archive/documentation/Ca... ): > In programm…
Those are implementation details. What's actually happening in all cases is my definition.
> also could you please answer my request for clarification in
Yes, your examples or the 5 million other implementations of event loops. You forgot to add gtk's for example :)
> in the mac os 8 documentation
... and I see no mention of stacks on Wikipedia:
https://en.wikipedia.org/wiki/Cooperative_multitasking
Which lumps in both the explicit event loop style and the syntactic sugar that got added later.
We could throw definitions around till kingdom come like this. And it's not the exact definition that's my problem.
Re: Niklaus Wirth has died
#370Earlier quoted context omitted.
The joke really only works if you use his first name! The complete joke is that "by value" means pronouncing first and last name to sound like "Nickles Worth".
"worth" alone still means "value" though