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 #include "temu-c/Support/Attributes.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 typedef struct temu_TimeSource temu_TimeSource;
18 typedef struct temu_Object temu_Object;
19 
20 typedef enum temu_ExecutionState {
24 } temu_ExecutionState;
25 
26 
27 /*!
28  * Run the current scheduler for a fixed number of steps
29  *
30  * \param steps Time in steps (in scheduler units).
31  */
33 
34 
35 /*!
36  * Run the current scheduler for a fixed time
37  *
38  * \param secs Time in simulated seconds
39  */
40 TEMU_API void temu_runForTime(double secs);
41 
42 /*!
43  * Run the current scheduler forever
44  */
45 TEMU_API void temu_run();
46 
47 /*!
48  * Step a processor in the current scheduler
49  *
50  * Note that, the other processors may run if the step exceeds the quanta.
51  * The step function currently runs processors in sequence,
52  * it is not running processors in parallel.
53  * This means that stepping is always deterministic.
54  *
55  * \param cpu The processor to step
56  * \param steps The number of steps or instructions to execute
57  */
59 
60 /*!
61  * Stop the current scheduler
62  *
63  * The function signals the scheduler to stop,
64  * and then waits until the scheduler is in the stopped state.
65  */
66 TEMU_API void temu_stop();
67 /*!
68  * Stop the current scheduler
69  *
70  * The function returns immediately, before the scheduler has stopped.
71  * The function is suitable for use in e.g. signal handlers.
72  */
74 
75 /*!
76  * Get the current execution status of TEMU
77  *
78  * \result Current execution status
79  */
80 
81 TEMU_API temu_ExecutionState temu_getExecutionState();
82 
83 /*!
84  * Get the number of processors in the global scheduler.
85  *
86  * \result Number of processors in global scheduler.
87  */
89 
90 /*!
91  * Get processor in global scheduler
92  * \param cpu Processor number to get
93  * \result Processor pointer as a time source.
94  */
95 TEMU_API temu_TimeSource* temu_getScheduledProcessor(unsigned cpu);
96 
97 /*!
98  * Serialize execution for some time when notification is triggered
99  * \param notificationSource Object emitting notification.
100  * \param notificationName Name of notification to intercept.
101  * \param seconds Number of seconds (simulated time, for which to serialize execution).
102  */
103 TEMU_API void
105  const char *notificationName, double seconds);
106 
107 #ifdef __cplusplus
108 } // extern c
109 #endif
110 
111 #endif /* ! TEMU_REGISTER_H */
temu_run
TEMU_API void temu_run()
temu_step
TEMU_API void temu_step(temu_TimeSource *cpu, int steps)
temu_runForTime
TEMU_API void temu_runForTime(double secs)
temu_getScheduledProcessorCount
TEMU_API unsigned temu_getScheduledProcessorCount()
temu_ExecutionState
temu_ExecutionState
Definition: Scheduler.h:20
temu_stop
TEMU_API void temu_stop()
teES_Stopped
@ teES_Stopped
Definition: Scheduler.h:21
temu_serializeOnNotification
TEMU_API void temu_serializeOnNotification(temu_Object *notificationSource, const char *notificationName, double seconds)
teES_Running
@ teES_Running
Definition: Scheduler.h:22
teES_Stepping
@ teES_Stepping
Definition: Scheduler.h:23
temu_Object
struct temu_Object temu_Object
Definition: Scheduler.h:18
temu_asyncStop
TEMU_API void temu_asyncStop()
temu_TimeSource
struct temu_TimeSource temu_TimeSource
Definition: Scheduler.h:17
temu_runForSteps
TEMU_API void temu_runForSteps(int64_t steps)