Structure of sem_t and implementation of semaphores

In C programming language why do we need a special sem_t type for defining the semaphore? Couldn't that been an integer?How is sem_t defined? How is the functions sem_post and sem_wait implemented? EDIT:An example implementation like GNU C library will be great.

Answers


Semaphores are OS kernel managed objects, so sem_t will be OS-specific, as will be the signal/wait calls since they also necessarily call into the OS kernel.

Usually, the semaphores are implemented by a unit count and a queue for any waiting threads.


Need Your Help

Upload string contents into google doc

c# .net google-docs google-docs-api

I wanna know if I can create a doc on google docs without uploading document..

Orphan constraints in SQL Server database

sql-server sql-drop default-constraint

Running the following query results in all constraints in our client's database. However, several rows in the result set don't seem to have a parent, i.e. parent_object_id = 0 and

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.