I am giving you are problem and I want it to simulate this in c++. Use thread and locks…
- User
I am giving you are problem and I want it to simulate this in c++. Use thread and locks judicialy
A. Load Monitoring The load monitoring section will collect the task load on different cores in the system and determine whether a load imbalance has occurred. In the kernel, we use the load_state_t structure to record the load information. As shown in Fig. 3, this structure records the number of ready tasks on the core, the number of sleep tasks, the currently running tasks, the queue where the sleep tasks are located, the sum of the time slice sizes of all ready tasks, and the size of each ready task and its time slice on the core.
The process of load monitoring is the process of populating the load_state_t structure based on the real-time load of the core. The load monitoring algorithm applied in this paper uses the time-slice size of the ready task on the core as the load evaluation factor Definition 1: The sum of the time-slice sizes of all ready tasks on a single processor is regarded as the processor load which is denoted by L. And T denotes the load proportion threshold. In our design, the value of T is 20%. A denotes the average processor load of all CPUs in the current system (except where the rootserver is located). The value of L/A is referred to as the degree of load on the core. Obviously, the larger the value, the heavier the load on the core. The load state S of the core can be determined by equation 1. S(L)=⎧⎩⎨⎪⎪heavynormal A∗(1+T)≥L≥A∗(1−T)lightL>A∗(1+T)L<A∗(1−T)L<A(1) View SourceRight-click on figure for MathML and additional features.
In equation 1, heavy means the current processor is in a heavy load state, and the tasks need to be migrated out. Normal means the current processor is in a normal load state, and no need for load adjustment. Light means the current processor is in a light load state, and there is a waste of CPU resources, and the load can be increased by adding new tasks.
Load monitoring can be triggered in two ways. First, it is triggered when a new task is created so that the relatively free core can be found to allocate that task. Second, it is performed periodically in the rootserver to get the load status of other cores and determine whether load balancing is needed through inter-core task migration.
B. Balancing decision From the above load monitoring, it can be found that there are two triggers for the balancing decision, triggered when a new task is created and triggered at timing. Therefore, the balancing decision algorithm needs to be designed for these two cases separately.
When a new task is created, the rootserver will use the analysis results of load monitoring to get the core ID that is relatively idle in the system and then assign the task to it. When triggered at timings, the rootserver analyzes the load on each core in the system and tries to get the task that will be migrated.
The steps of the algorithm are shown as follows.
The rootserver traverses the load of all cores, gets all ready tasks running on them and their time-slice sizes, and saves them in a two-dimensional array task_info_cpus with the task_info_t structure as a member of the array.
- Assistant