Page 1 of 1

vcos_sempahore vs posix semaphore

Posted: Thu Sep 13, 2018 10:03 am
by longo92
I don't know if is the right section where ask. I see on the mmal example code that are used vcos_semaphore: why don't use posix (http://www.csc.villanova.edu/~mdamian/t ... ixsem.html)? Or vcos sempahore are just a wrapper of posix sem?

Re: vcos_sempahore vs posix semaphore

Posted: Thu Sep 13, 2018 11:13 am
by 6by9
vcos is an operating system abstraction. (VideoCore Operating System) See https://github.com/raspberrypi/userland ... rface/vcos for the full source of vcos.
In the case of vcos_semaphore_create on pthreads, see https://github.com/raspberrypi/userland ... orm.h#L324

It allows the resulting code to be run on a variety of operating systems, including pthreads, ThreadX, Symbian, Windows, and Nucleus. Back in Broadcom there were a number of test apps that would run on a number of those operating systems without modification, which makes cross platform regression testing significantly easier.
MMAL code in particular shares a significant proportion of the core code between the host OS (typically pthreads for the Pi) and ThreadX for the VPU, hence the need for an OS independent abstraction.