I can nto find anything that explains semaphores well. From what I understand, you can create an array of the type sem_t , for instance. Like a "semaphore array", I guess. And you use loops somehow to create them. Or can somebody explain this to me, please? I'm trying to do a problem about customers in a supermarket who are ready to pay and pick a lane ( semaphores ), and up to 4 lanes. They pick lowest numbered lane and with the fewest customers.

Recommended Answers

All 2 Replies

I don't see why (nor how) semaphores would be used in this problem. My solution would have a 4-integer array representing the lanes which contains the number of customers in it. A loop looks at the values and finds the minimum value. That's your chosen lane.

Well, that's not the entire problem. There's more to it. It wants me to do other things, as well. And I want to practice it. I just need help with semaphores as I can't find much that explains it well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.