Create an instance of the basic process:
A total of three parts: Create a process, process self-start, and the body part of a process
1 /*declares a process named Hello_world_process and led_process2 the process macro actually declares a function and defines a process control block,3 newly created process next pointer to NULL, process name "Hello World" and "led"*/4PROCESS (Hello_world_process,"Hello World");5PROCESS (Led_process,"led");6 /*the process needs to start automatically, that is, when the node starts the process*/7Autostart_processes (&led_process,&hello_world_process);8 9 /*the body part of the hello_world_process process*/Ten process_thread (hello_world_process, Ev, data) One { A /*All processes must have this statement before they start executing.*/ - Process_begin (); - theprintf"Hello world:) \ n"); - - /*All processes must have this statement at the end*/ - process_end (); + } - /*the subject part of the led_process process*/ + process_thread (led_process, Ev, data) A { atProcess_begin ();//macros are used to assist in saving breakpoint information (number of rows), - //the code you want to implement must be placed between the macro Process_begin and Process_end - while(1) - { - Static structEtimer et; -Etimer_set (&et, clock_second/Ten); inProcess_wait_event_until (etimer_expired (&et)); - toLED_ON (0); +printf"LED0----on-----\ r \ n"); - theLed_off (1); *printf"LED1-----OFF-----\ r \ n"); $ Panax NotoginsengEtimer_set (&et, clock_second/Ten); -Process_wait_event_until (etimer_expired (&et)); the +Led_off (0); Aprintf"LED0-----OFF-----\ r \ n"); theLED_ON (1); +printf"LED1----on-----\ r \ n"); - $ } $Process_end ();//macros are used to assist in saving breakpoint information (number of rows) -}
Then in the main function:
1 intMain ()2 {3 4 boardinit ();5DEBUG ("Boardinit done!");6printf"initialising\r\n"); 7Clock_init ();//Clock Initialization8Process_init ();//Process Initialization9 TenProcess_start (&etimer_process, NULL);//start the system process OneAutostart_start (autostart_processes);//start the user self-start process Aprintf"Processes running\r\n"); - while(1) { - Do the { - } - while(Process_run () >0); -idle_count++; + } -}
Reference Blog: http://blog.csdn.net/ferlansue/article/details/7256964
Process Analysis for CONTIKI-MAIN.C files