I have a system which consists of multiple threads, lets say process A, B and C and these processes are completely written in SDL which eventually gets converted to C language after compilation.
I also have an equivalent simulation environment with the same processes, which would run on only one thread but simulate each of these processes. Basically, each of the processes A, B and C get recompiled with a different set of options and somehow everything works as one process (typical of IBM-SDL simulation). This theoretically represents a light-weighted system of the real process and everything works as one process. Now in this simulation environment, There are three files lets that get generated, lets say :- A.c B.c and C.c. Obviously in this simulation, there is no room for pre-emption of a process. If a message X comes to process A, A would completely process this signal and then go to the next state transition and ONLY then the next process would be running when next signal comes in to the system.
I am trying to implement pre-emption in this simulation system without threads. As it turns out, in simulation each of these files can be edited (via some script) and I know the exact possible pre-emption points during the course of execution of a particular set of signals one after another.
My question is :- If I insert conditional goto / break statements (after lets assume every line in each A.c, B.c and C.c) and jump from one file to another during the code execution, have I implement a simulated threaded environment ?
Or Am I missing something here ?
I know its a very broad question and my OS knowledge is not great. Also, I know that there can be many conditions possible for such a scenario to work. But lets assume I find a way to fix those problems. My question boils down to this :- If "smart" goto can be equivalently used as a substitute for Multiple threads in single threaded environment ?? Timing is not a problem for me, as I am working with a simulated time. System load etc, don't matter. I was thinking of adding a control function call after every step in each of these files A.c, B.c and C.c and in this control function I can check if i want to return, or jump to some other place and continue to execute from another file. What kind of implementation difficulties would I face in such an approach ?