Machine language multitasking example for raspberry Pi 4B

Question reason: Windows 10 DosBox and VirtualBox allows DOS .com files to run in separate instances. Both even allows protected mode [IN/OUT] instruction execution.

How this done? Don’t know … yet.

Can anyone show machine language [not assembler] code to run two raspberry Pi 4B mutlitask apps which: one instance blinks green activity LED three times slow. second instance blinks LED 6 times fast.

Reason amplification: DosBox and VirtualBox MUST load app starting at memory location 0 for .com app to run.

Can this be done under Linux?

I don’t know whether I understand your question correctly. I am really not an expert in that field.

Are you really asking for a machine code example? A series of hexadecimal numbers?
I can’t see how that could be helpful in any way. Besides: At this level, instructions are agnostic of the running operating system and yes: Every processor since the 80286 (introduced in 1982) supports protected mode instructions, i.e. multitasking.

Now, back to your example with the blinking LEDs:

Examples of how to control LEDs attached to the PI are described in the documentation of the GPIO API (application programming interface).

Now, say you have written two blink apps for a connected LED, be it in C or Python, slowblink and fastblink, both taking the number of times to blink as command line parameter and have compiled them if necessary.

Now, assuming, you’re running Raspbian or any other Linux on your Pi, you can just open a text editor and create a new file blink.sh with the content:

#!/bin/bash
slowblink 3 &
fastblink 6 &

If you now execute blink.sh, the two blinking signals should overlap.

The & sign after the command lets the shell interpreter execute the command in the background and makes it jump right to the execution of the next one.

Is this an answer to your question?

1 Like