-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessor.h
More file actions
75 lines (58 loc) · 2.24 KB
/
Copy pathprocessor.h
File metadata and controls
75 lines (58 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* SPDX-License-Identifier: MIT */
#pragma once
#include <stdbool.h>
#include <thread.h>
typedef struct processor_set processor_set_t;
typedef enum processor_state {
PROCESSOR_STATE_NA = 0, /* Not Available */
PROCESSOR_STATE_SHUTDOWN, /* Going offline */
PROCESSOR_STATE_STARTING, /* Being started */
PROCESSOR_STATE_IDLE, /* Idle */
PROCESSOR_STATE_DISPATCHING, /* Dispatching (Idle -> Running) */
PROCESSOR_STATE_RUNNING, /* Running */
} processor_state_t;
struct processor_set {
list_node_t pset_list_node; /* List of processor sets. */
list_t processor_list; /* List of processors belonging to this processor
set. */
uint32_t processor_count; /* Count of processor in this set. */
list_t threads;
uint32_t thread_count; /* Total threads assigned to this processor set. */
list_t tasks; /* Tasks assigned. */
uint32_t task_count; /* Count of task assigned. */
};
typedef struct processor {
list_node_t pset_node;
list_node_t plist_node;
bool is_smt; /* Simultaneous multithreading. */
processor_state_t state; /* Current processor state. */
thread_t *current_thread; /* Thread currently running on this processor. */
thread_t idle_thread;
uint32_t cpu_number;
processor_set_t *pset; /* Processor set this processor belongs to. */
} processor_t;
extern list_t processor_list;
/**
* Initialize the processor set system.
*/
void pset_init(processor_set_t *pset);
void pset_add_processor(processor_t *processor, processor_set_t *pset);
void pset_remove_processor(processor_t *processor, processor_set_t *pset);
void pset_add_thread(processor_set_t *pset, thread_t *thread);
void pset_remove_thread(processor_set_t *pset, thread_t *thread);
/**
* Initialize the processor set system and the bootstrap
* processor.
*/
void processor_bootstrap(void);
/**
* Initialize a processor object and assign it to a processor-set.
*
* @param processor Processor object to initialize.
*
* @param num Processor number.
*
* @param processor_set Processor-set that includes this processor.
*/
void processor_init(processor_t *processor, uint32_t num,
processor_set_t *processor_set);