Forum Discussion
Altera_Forum
Honored Contributor
15 years agoHelp in semaphores
Hi Can anyone Plz Help me in Semaphores in MicroC os2 .Just Give me some Working Code of two task swithched on semaphores.Whether the task print hello word .it is fine.I have Used the the Functio...
Altera_Forum
Honored Contributor
15 years agoCreating the Semaphore
// create Semaphore
m_t_sem_access = OSSemCreate(0);
if (m_t_sem_access == NULL)
{
// just in case some error handling
}
Accessing a semaphore protected area
OSSemPend(m_t_sem_access,
L_SPI_ACCESS_TIMEOUT,
&proc_i_error);
switch (proc_i_error)
{
// error handling
....
}
Removing the Lock
proc_i_error = OSSemPost(m_t_sem_access);
if (proc_i_error != OS_NO_ERR)
{
....
}
This code snippets are taken from my current project. The semaphore is used to protect access to a hardware device. Karsten