This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

alternate way in absence of get_semaphore_value

I am implementing a uart communication, where i have various functions and/or tasks which may want to perform transmission using uart. Hence prior to new transmission on uart, i want to ensure that the resource (uart) is not already in use. this can be achieved by a binary semaphore whose value can be checked prior to new transmissions. But keil RTOS doesnt have sem_getvalue, in absence of which i am unable to think of any way of implementation.

one way around is to have a global flag. But currently trying to use any idea by which i can avoid using a global flag. In case of no other way, will have to use global flag.

any suggestions?

Parents
  • if transmission is in progress, then wait untill the transmission is completed and then send the data (which can be done with help of a semaphore).

    Yes. But it appears you really have no idea how that's supposed to be done with the help of a semaphore.

    I'm afraid I have to recommend that you stop what you're doing, right here and now, and go back to the fundamentals. Pick up a textbook. Really learn what a semaphore is, and what it does. Learn what P() and V() are, and why these are enough to do what a semaphor is meant to do. Only then does it make any sense for you to continue with the task at hand.

Reply
  • if transmission is in progress, then wait untill the transmission is completed and then send the data (which can be done with help of a semaphore).

    Yes. But it appears you really have no idea how that's supposed to be done with the help of a semaphore.

    I'm afraid I have to recommend that you stop what you're doing, right here and now, and go back to the fundamentals. Pick up a textbook. Really learn what a semaphore is, and what it does. Learn what P() and V() are, and why these are enough to do what a semaphor is meant to do. Only then does it make any sense for you to continue with the task at hand.

Children
No data