Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dramforever/threaded-code-demo
Some demonstrations of threaded code techniques
https://github.com/dramforever/threaded-code-demo
Last synced: about 1 month ago
JSON representation
Some demonstrations of threaded code techniques
- Host: GitHub
- URL: https://github.com/dramforever/threaded-code-demo
- Owner: dramforever
- Created: 2023-11-19T12:07:51.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-19T17:35:08.000Z (about 1 year ago)
- Last Synced: 2023-11-20T13:31:54.324Z (about 1 year ago)
- Language: C
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Threaded code demo
Complete demos for my article Threaded code explained in C at
Some demonstrations of threaded code techniques
- `bytecode.c`: Bytecode (Not technically threaded)
- `direct.c`: Direct threaded code
- `indirect.c`: Indirect threaded code
- `pctc.c`: Primitive-centric threaded code
- `pctc_opt.c`: Primitive-centric threaded code (Optimized to encourage the compiler to use registers)Primitive-centric threaded code is described in [Direct or Indirect Threaded?][gforth-pctc] in the Gforth manual.
[gforth-pctc]: https://gforth.org/manual/Direct-or-Indirect-Threaded_003f.html
Each of the demo files needs to be compiled along with / linked to `main.c` such as:
```console
$ gcc -o direct direct.c main.c
$ ./direct # Run the demo
```Or equivalently, using the convenience `Makefile`:
```console
$ make direct # Build one demo
$ make # Build everything
```Each demo simply prints a number to show that it will run. The expected outputs are:
- `bytecode`: `2`
- `direct`: `2`
- `indirect`: `4`
- `pctc`: `6`
- `pctc_opt`: `6`