A method for simulation of a real-time system on a workstation; the realtime system comprising target hardware and at least one task ( τ i) executed by the target hardware; the method comprises: using a block-oriented simulation system for simulating a model of the realtime system; wherein the model is represented by a block diagram composed of at least one block ( b i) that represents the at least one task ( τ i), wherein, for the purpose of simulation, each task ( τ i) is implemented by a task function composed of a sequence of one or more code segments, wherein an execution time concerning execution by the target hardware is associated with each code segment, and wherein the simulation system includes a simulation engine that controls the execution of each task ( τ i); wherein each task function is executed in a separate task thread (TT i), and when the execution of the task function reaches the end of a code segment, a current simulation time provided by the simulation engine is compared with a desired execution time and execution of the task thread (TT i) is suspended, when the current simulation time has not reached the desired execution time; the desired execution time being determined based on the execution times associated with the one or more code segments; and wherein the simulation engine performs a plurality of simulation steps, in which the simulation engine executes, for each block ( b i), at least a first callback function and a second callback function, wherein the first callback function is configured to trigger a context switch to start execution of the respective task thread (TT i), wherein the second callback function is configured to trigger the context switch to resume execution of the respective task thread (TT i), and wherein, before triggering the context switch, the first and the second callback function are configured to set a variable indicative of the specific callback function that triggers the context switch, wherein the variable is used to distinguish whether the simulation engine has invoked the first callback function or the second callback function. using a block-oriented simulation system for simulating a model of the realtime system; wherein the model is represented by a block diagram composed of at least one block ( b i) that represents the at least one task ( τ i), wherein, for the purpose of simulation, each task ( τ i) is implemented by a task function composed of a sequence of one or more code segments, wherein an execution time concerning execution by the target hardware is associated with each code segment, and wherein the simulation system includes a simulation engine that controls the execution of each task ( τ i); wherein each task function is executed in a separate task thread (TT i), and when the execution of the task function reaches the end of a code segment, a current simulation time provided by the simulation engine is compared with a desired execution time and execution of the task thread (TT i) is suspended, when the current simulation time has not reached the desired execution time; the desired execution time being determined based on the execution times associated with the one or more code segments; and wherein the simulation engine performs a plurality of simulation steps, in which the simulation engine executes, for each block ( b i), at least a first callback function and a second callback function, wherein the first callback function is configured to trigger a context switch to start execution of the respective task thread (TT i), wherein the second callback function is configured to trigger the context switch to resume execution of the respective task thread (TT i), and wherein, before triggering the context switch, the first and the second callback function are configured to set a variable indicative of the specific callback function that triggers the context switch, wherein the variable is used to distinguish whether the simulation engine has invoked the first callback function or the second callback function.