In contiki os, there are a lot of functions predefined in the core file. During programming in contiki os, programmers require to follow the contiki programming style to create their own code. These functions are PROCESS_BEGIN(), PROCESS_END(), PROCESS_YIELD() and so on. All of the functions have its own uses but some of it only slightly difference between each other.
This week I am doing the on running simple task using contiki os. Function used are PROCESS_BEGIN, PROCESS_END, PROCESS_YIELD, PROCESS_WAIT_EVENT, PROCESS_WAIT_EVENT_UNTIL, PT_SEM_INIT, PT_SEM_SIGNAL, PT_SEM_WAIT.
PROCESS_BEGIN() and PROCESS_END() are the functions used at the begin and the end of every single process thread. The code between this two functions are the main task we need to execute. Using these two functions is enough to do a single simple process thread.
PROCESS_YIELD() is a functions that used to yield the currently process thread and execute the following process thread. After finish executed the following process thread, it will return and continue the previous process thread. So that, this function can be used to execute multiple function. In addition, PROCESS_WAIT_EVENT() is the another name of PROCESS_YIELD(). In the source code, we can found that “#define PROCESS_WAIT_EVENT() PROCESS_YIELD()”.
PROCESS_WAIT_EVENT_UNTIL(c) is wait an event to be posted when an extra condition become true. The condition usually stated is an event timer. When the etimer condition is fulfilled, it will execute the process thread.
In contiki os also have function to do a semaphore process, which are PT_SEM_INIT, PT_SEM_SIGNAL, PT_SEM_WAIT.
PT_SEM_INIT(s, c) is used for initialization of semaphore and together with a value.
PT_SEM_SIGNAL(pt, s) is carries out a signal to the the respective semaphore. Once this code is executed, it will give signal to the PT_SEM_WAIT(pt, s) and run the process.
During running tasks in my contiki os cpu and platform, the contiki-main.c need to be initialize to ensure the program can be execute well. This week I failed to porting etimer and clock to my contiki os, so that I unable to execute the function like PROCESS_WAIT_EVENT_UNTIL(c) which require condition in it.