How can I start multiple processes in parallel to create a congestion in CPU usage? Below is the code I was trying:-
#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();
}
but, this gives error as following:-
/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}
Please guide me through. Any alternative way/suggestion of creating CPU congestion would also be helpful.
Behind the macro AUTOSTART_PROCESSES
, a structure definition is hidden.
#define AUTOSTART_PROCESSES(...) \
struct process * const autostart_processes[] = {__VA_ARGS__, NULL}
By calling twice AUTOSTART_PROCESSES
, you define the structure twice.
Solution:
Given the macro parameters, I guess that you should write:
AUTOSTART_PROCESSES(&cpu_load_process_1, &cpu_load_process_2);
Instead of
AUTOSTART_PROCESSES(&cpu_load_process_1);
AUTOSTART_PROCESSES(&cpu_load_process_2);