PHP offers an extension for using System V semaphores. If your operating system supports this feature, you may add this extension to your installation of PHP. At the time of this writing, only the Solaris, Linux, and AIX operating systems were known to support semaphores. Semaphores are a way to control a resource so that it is used by a single entity at once, and they were inspired by the flags used to communicate between ships. The idea to use an integer counter to ensure single control of a resource was described first by Edsger Dijkstra in the early 1960s for use in operating systems. Semaphores are a standard topic for college computer science courses, and you will find adequate descriptions in books about operating systems.
boolean sem_acquire(integer identifier)
The sem_acquire function attempts to acquire a semaphore you've identified with the sem_get function. The function will block until the semaphore is acquired. Note that it is possible to wait forever while attempting to acquire a semaphore. One way is if a script acquires a semaphore to its limit and then tries to acquire it another time. In this case the semaphore can never decrement.
If you do not release a semaphore with sem_release, PHP will release it for you and display a warning.
integer sem_get(integer key, integer maximum, integer permission)
Use sem_get to receive an identifier for a semaphore. If the semaphore does not exist, it will be created. The optional maximum and permission arguments are used only during creation. The maximum argument controls how many times a semaphore may be acquired. It defaults to 1. The permission argument controls read and write privileges to the semaphore in the same way file permissions do. It defaults to 0x666, which is read and write access for all users. The key argument is used to identify the semaphore among processes in the system. The integer returned by sem_get may be unique each time it is called, even when the same key is specified.
boolean sem_release(integer identifier)
Use sem_release to reverse the process of the sem_acquire function
PHP Related Interview Questions
|PHP Interview Questions||MySQL Interview Questions|
|PHP+MySQL Interview Questions||Drupal Interview Questions|
|MYSQL DBA Interview Questions||PHP5 Interview Questions|
|WordPress Interview Questions||Joomla Interview Questions|
|CakePHP Interview Questions||CodeIgniter Interview Questions|
|PHP7 Interview Questions|
An Introduction To Php
Variables, Operators, And Expressions
Classes And Objects
I/o And Disk Access
Time, Date, And Configuration Functions
Parsing And String Evaluation
Sorting Searching And Random Numbers
Integration With Html
Efficiency And Debugging
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.