如何并行启动多个进程以造成 CPU 使用率拥塞?以下是我尝试的代码:-
#include "contiki.h"
#include <stdio.h>
PROCESS(cpu_load_process_1, "CPU Loading Process 1");
PROCESS(cpu_load_process_2, "CPU Loading Process 2");
PROCESS(cpu_load_process_3, "CPU Loading Process 3");
PROCESS(cpu_load_process_4, "CPU Loading Process 4");
AUTOSTART_PROCESSES(&cpu_load_process_1);
AUTOSTART_PROCESSES(&cpu_load_process_2);
PROCESS_THREAD(cpu_load_process_1, ev, data)
{
PROCESS_BEGIN();
PROCESS_END();
}
PROCESS_THREAD(cpu_load_process_3, ev, data)
{
PROCESS_BEGIN();
PROCESS_END();
}
但是,这会产生如下错误:-
/home/user/contiki-3.0/core/./sys/autostart.h:48:24: error: redefinition of ‘autostart_processes’
struct process * const autostart_processes[] = {__VA_ARGS__, NULL}struct process * const autostart_processes[] = {__VA_ARGS__, NULL}
请指导我完成。任何造成 CPU 拥塞的替代方式/建议也会有所帮助。