#include&lt;stdio.h&gt;   #include&lt;fcntl.h&gt;   #include&lt;sys/stat.h&gt;   #include&lt;semaphore.h&gt;&nbsp;   int main&#40;&#41;   &#123;       sem_t* sem_id;       int value;       sem_id = sem_open&#40;&quot;sem_value&quot;,O_CREAT,0666,0&#41;;       if&#40;sem_id == SEM_FAILED&#41;           perror&#40;&quot;sem_open&quot;&#41;;       if&#40;sem_getvalue&#40;sem_id,&amp;value&#41; == -1&#41;           perror&#40;&quot;sem_getvalue&quot;&#41;;       printf&#40;&quot;%d\n&quot;,value&#41;;       sem_wait&#40;sem_id&#41;;       printf&#40;&quot;Sanfoundry\n&quot;&#41;;       if&#40;sem_close&#40;sem_id&#41; == -1&#41;           perror&#40;&quot;sem_close&quot;&#41;;       return 0;   &#125;
A. 0
B. Sanfoundry
C. both (a) and (b)
D. none of the mentioned
Answer:A
#include&lt;stdio.h&gt;   #include&lt;fcntl.h&gt;   #include&lt;sys/stat.h&gt;   #include&lt;semaphore.h&gt;&nbsp;   int main&#40;&#41;   &#123;       sem_t* sem_id;       int value;       sem_id = sem_open&#40;&quot;sem_value&quot;,O_CREAT,0666,0&#41;;       if&#40;sem_id == SEM_FAILED&#41;           perror&#40;&quot;sem_open&quot;&#41;;       if&#40;sem_getvalue&#40;sem_id,&amp;value&#41; == -1&#41;           perror&#40;&quot;sem_getvalue&quot;&#41;;       printf&#40;&quot;%d\n&quot;,value&#41;;       sem_wait&#40;sem_id&#41;;       printf&#40;&quot;Sanfoundry\n&quot;&#41;;       if&#40;sem_close&#40;sem_id&#41; == -1&#41;           perror&#40;&quot;sem_close&quot;&#41;;       return 0;   &#125;
A. 0 B. Sanfoundry C. both (a) and (b) D. none of the mentioned
Explanation:The sem_getvalue() is used to get the current value of the semaphore.