Thread: How I can create array with 3 semaphores (1,0,0)

  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    1

    How I can create array with 3 semaphores (1,0,0)

    Hello everyone, I'm new in C and I don't know how to do this.Can someone help me?

  2. #2
    Registered User
    Join Date
    Apr 2019
    Posts
    2

    Post

    Hello ExxCal ,

    Not sure if I understood correctly what you want to do, having a code in my hands would make it easier, but I think this is what you are looking for.

    Code:
    int sem_init(sem_t *sem, int pshared, unsigned int value);
    
    For example : 
    
    for(i=0; i < 5; i++)
      sem_init(&sem_name, 0, 10);
    You can have some further info in case you are interrest from this link : POSIX Semaphores

  3. #3
    Registered User
    Join Date
    Apr 2013
    Posts
    1,646
    What operating system? In the case of windows, mutexes and semaphores are "handles", and creating an array of handles is not an issue, and is required if using WatiForMultipleObjects.

    WaitForMultipleObjects function (synchapi.h) | Microsoft Docs

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. create and populate create bidimensional array
    By darkducke in forum C Programming
    Replies: 0
    Last Post: 12-03-2010, 07:06 AM
  2. how do i create an array...
    By qubit67 in forum C Programming
    Replies: 9
    Last Post: 04-10-2007, 11:54 PM
  3. How to copy array without create a new one
    By thone in forum C Programming
    Replies: 11
    Last Post: 08-02-2004, 01:24 AM
  4. create an array
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 04-22-2002, 08:21 PM
  5. using new to create a two-dimensional array
    By pianorain in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2002, 09:20 AM

Tags for this Thread