1. 22

Yesterday I ranted about the duality of FSM’s and Threads and against Heirarchical State Machines (and Threads) and life in general yesterday….

Today I bumped into a some confirmation of my attitude….

(I note /u/FriendlySock submitted the first one 5 months ago (to zero comment), I hope this submission doesn’t cause him to morph into /u/AngerSock)

Also interesting is…

Which I think concentrates too much on the scary details of hardware caching and NUMA architectures and not nearly enough on the conceptual simplicity of “Only one thread operates on a data structure”.

Again my personal experience is that this ffwd-like designs are a great architecture…. but requires high discipline, and humans are very very Bad at being highly disciplined.

The immutable functional programming types may now wisely gloat in the beards.

  1.  

  2. 3

    “Only one thread operates on a data structure” is a simple concept, but the resulting system is not simple anymore. The concept encourages programmers to avoid shared data, which makes concurrency trivial and it is easy to parallelize.

    The problem is that you now need message passing between threads, because you cannot share data structures. This effectively turns the collection of threads into a distributed system, where you need to design a protocol for correct interaction. Getting that correct is hard.

    A similar discussion is macro- vs microkernels (Torvalds vs Tanenbaum). Tanenbaum argues to split the OS into many simple processes, while Torvalds argues that a macrokernel with shared data is easier.

    Today you need parallelism to achieve good throughput on a multicore CPU. If you can get the parallelism without having to deal with the concurrency on shared data, do that! To do that safely you need a type system, which can prevent side effects, though.

    1. 3

      Reminds me of the parable of four horses, which I’ll talk about once I get home.

      1. 3

        Here’s what their work turned into if anyone is curious:

        http://capriccio.cs.berkeley.edu/pubs/capriccio-sosp-2003.pdf

        1. 1

          I’m confused. The duality paper by Lauer and Needham compares Message-Oriented and Procedure-Oriented. Looking at the description they are not talking about threads or events?

          1. 1

            I was also confused about duality of FSM’s and Threads. As a compiler guy, I know FSMs primarily as the conceptual tool for lexical analysis. Related are regular expressions, which are usually modelled as FSMs. Lexers and regexes are not dual to threads in any way.

            When I read the article of “yesterdays rant”, I understood you were talking about FSMs as the “implementation tool” as used in embedded systems. I agree that is does not matter, if you model a program as FSM or thread: There is state and state changes in some way.