Hello Dhiraj, In this simple scenario you can use the semaphore. When buffer is unlocked (i.e. available), the semaphore count should be 1. Your application needs to execute tx_semaphore_get() before accessing the buffer. If the semaphore is not available, it will wait indefinitely (or you can make it skip ahead by using a timeout and checking the return value. Once application has finished using the buffer, tx_semaphore_ceiling_put() is executed to make it available to other parts of code that may want to access it. Here's a snippet of code that should do what I described above: static UCHAR memory_buffer[1024]; UINT status; /* Make buffer available */ tx_semaphore_ceiling_put(&semaphore, 1); /* Some application code */ /* Access the semaphore */ status = tx_semaphore_get(&semaphore, TX_NO_WAIT); if (!status) { /* Resource available */ /* Handle the resource */ tx_semaphore_ceiling_put(&semaphore, 1); } else if (TX_NO_INSTANCE == status) { /* Resource locked */ } else { /* Error occurred */ } Regards
↧