TEMU  4.2
The Terma Emulator
Scheduler.h
Go to the documentation of this file.
1 //===-- temu-c/Scheduler.h - TEMU Scheduler API -----------------*- C++ -*-===//
2 //
3 // TEMU: The Terma Emulator
4 // (c) Terma 2023
5 // Authors: Mattias Holm <maho (at) terma.com>
6 //
7 //===----------------------------------------------------------------------===//
8 #ifndef TEMU_SCHEDULER_H
9 #define TEMU_SCHEDULER_H
10 #include <stdint.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 typedef struct temu_TimeSource temu_TimeSource;
17 
18 typedef enum temu_ExecutionState {
22 } temu_ExecutionState;
23 
24 
25 /*!
26  * Run the current scheduler for a fixed number of steps
27  *
28  * \param steps Time in steps
29  */
30 void temu_runForSteps(int64_t steps);
31 
32 
33 /*!
34  * Run the current scheduler for a fixed time
35  *
36  * \param secs Time in simulated seconds
37  */
38 void temu_runForTime(double secs);
39 
40 /*!
41  * Run the current scheduler forever
42  */
43 void temu_run();
44 
45 /*!
46  * Step a processor in the current scheduler
47  *
48  * Note that, the other processors may run if the step exceeds the quanta.
49  * The step function currently runs processors in sequence,
50  * it is not running processors in parallel.
51  * This means that stepping is always deterministic.
52  *
53  * \param cpu The processor to step
54  * \param steps The number of steps or instructions to execute
55  */
56 void temu_step(temu_TimeSource *cpu, int steps);
57 
58 /*!
59  * Stop the current scheduler
60  *
61  * The function signals the scheduler to stop,
62  * and then waits until the scheduler is in the stopped state.
63  */
64 void temu_stop();
65 /*!
66  * Stop the current scheduler
67  *
68  * The function returns immediately, before the scheduler has stopped.
69  * The function is suitable for use in e.g. signal handlers.
70  */
71 void temu_asyncStop();
72 
73 /*!
74  * Get the current execution status of TEMU
75  *
76  * \result Current execution status
77  */
78 
79 temu_ExecutionState temu_getExecutionState();
80 
81 /*!
82  * Get the number of processors in the global scheduler.
83  *
84  * \result Number of processors in global scheduler.
85  */
87 
88 /*!
89  * Get processor in global scheduler
90  * \param cpu Processor number to get
91  * \result Processor pointer as a time source.
92  */
93 temu_TimeSource* temu_getScheduledProcessor(unsigned cpu);
94 
95 
96 #ifdef __cplusplus
97 } // extern c
98 #endif
99 
100 #endif /* ! TEMU_REGISTER_H */
temu_stop
void temu_stop()
temu_getExecutionState
temu_ExecutionState temu_getExecutionState()
temu_asyncStop
void temu_asyncStop()
temu_ExecutionState
temu_ExecutionState
Definition: Scheduler.h:18
teES_Stopped
@ teES_Stopped
Definition: Scheduler.h:19
temu_getScheduledProcessorCount
unsigned temu_getScheduledProcessorCount()
temu_runForTime
void temu_runForTime(double secs)
temu_step
void temu_step(temu_TimeSource *cpu, int steps)
temu_runForSteps
void temu_runForSteps(int64_t steps)
teES_Running
@ teES_Running
Definition: Scheduler.h:20
teES_Stepping
@ teES_Stepping
Definition: Scheduler.h:21
temu_TimeSource
struct temu_TimeSource temu_TimeSource
Definition: Scheduler.h:16
temu_run
void temu_run()
temu_getScheduledProcessor
temu_TimeSource * temu_getScheduledProcessor(unsigned cpu)