I'm playing a bit with parallel programming in C; Hence whatever solution I see in the articles I'm reading are built on top of Threads or stuff like OpenMP, MPI, Select on Windows or Fork on *nix; I got the following questions:
Can a single process go-parallel on a single thread and without Forking itself?
Are there any other ways of writing parallel code, but with very basic building blocks that are available in C? Something that could be done by manually moving bits around, purely in C built-in functions -- not using a high-level library that makes use of operating system features?
Also the purpose of the question is to get a better understanding of how parallel programming works in a close-to-metal world. I don't have any interest to do micro-optimizations or reinventing the libraries.
Update
I'm basically thinking of writing Callback functions and let them get called when an Event happened; But I'm not sure if it will make it parallel or not.
Can a single process go-parallel on a single thread and without Forking itself?
That is up to the compiler. The compiler is free to implement instructions between sequence points any way it wants, although most compilers don't parallellize across multiple cores in single-threaded programs.
Example: Compilers for vector processors (like the Cray supercomputers) or for GPUs (graphics cards) use unrolling to parallellize loops.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With