General understanding of messages, semaphores etc

Topics related to events, messages or semaphores

General understanding of messages, semaphores etc

Postby MD5003 » Mon May 21, 2018 9:28 am

Being a mechanical engineer I have some trouble understanding some of the principles in this whole message and semaphore system.
I am currently working on a robotics project using a teensy 3.6 and plan to use cocoOS for programming.

I have read some articles (mainly wikipedia) about multi tasking and what messages and semaphores are, but yet the whole principle is probably too abstract for me, not having the background of an actual programmer (especially in µc programming).

Could it cause problems to use global variables to communicate between different tasks instead of messages? How are semaphores used in general?

Are there any good ressources, preferably cocoOS samples, for seeing messages and semaphores "in action"?
MD5003
 
Posts: 1
Joined: Mon May 21, 2018 9:19 am

Re: General understanding of messages, semaphores etc

Postby peter » Mon May 21, 2018 9:57 am

Hi,
thanks for planning to use cocoOS!

Semaphores are used to protect shared resources.
A global variable is a shared resource. If one task are updating it, it could potentially be interrupted, before the update operation is complete, by another task that tries to read the shared variable.
So it will read corrupted data.
In this case you should protect the variable by a semaphore.

By using messages in cocoOS instead, the OS takes care of protecting data and delivers it to the recipient.

If you mail me at info@cocoos.net and give me some hints about what you want to accomplish, I could help you get started.

Regards
Peter
peter
Site Admin
 
Posts: 24
Joined: Wed Mar 07, 2012 9:32 am


Return to Events, Messages and Semaphores

Who is online

Users browsing this forum: No registered users and 0 guests

cron