Class: SysVIPC::Semaphore

Inherits:
Object
  • Object
show all
Includes:
SysVIPC
Defined in:
lib/SysVIPC.rb

Constant Summary

Constants included from SysVIPC

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SysVIPC

#check_result

Instance Attribute Details

#semidObject (readonly)

Returns the value of attribute semid.



203
204
205
# File 'lib/SysVIPC.rb', line 203

def semid
  @semid
end

Instance Method Details

#getallObject

Return an Array containing the value of each semaphore in the set. See semctl(2).



219
220
221
222
223
# File 'lib/SysVIPC.rb', line 219

def getall
  res, array = semctl(@semid, 0, GETALL)
  check_result(res)
  array
end

#getncnt(semnum) ⇒ Object Also known as: ncnt

Get the number of processes waiting for a semaphore to become non-zero. See semctl(2).



249
250
251
# File 'lib/SysVIPC.rb', line 249

def getncnt(semnum)
  semctl(@semid, semnum, GETNCNT)
end

#getpid(semnum) ⇒ Object Also known as: pid

Get the process ID of the last semaphore operation. See semctl(2).



241
242
243
# File 'lib/SysVIPC.rb', line 241

def getpid(semnum)
  semctl(@semid, semnum, GETPID)
end

#getval(semnum) ⇒ Object Also known as: val

Get the value of semaphore semnum. See semctl(2).



233
234
235
# File 'lib/SysVIPC.rb', line 233

def getval(semnum)
  semctl(@semid, semnum, GETVAL)
end

#getzcnt(semnum) ⇒ Object Also known as: zcnt

Get the number of processes waiting for a semaphore to become zero. See semctl(2).



257
258
259
# File 'lib/SysVIPC.rb', line 257

def getzcnt(semnum)
  semctl(@semid, semnum, GETZCNT)
end

#ipc_rmidObject Also known as: rm

Remove. See semctl(2).



284
285
286
# File 'lib/SysVIPC.rb', line 284

def ipc_rmid
  check_result(semctl(@semid, 0, IPC_RMID))
end

#ipc_set(semid_ds) ⇒ Object Also known as: semid_ds=

Set the Semid_ds object. See semctl(2).



273
274
275
276
277
278
279
# File 'lib/SysVIPC.rb', line 273

def ipc_set(semid_ds)
  unless Semid_ds === semid_ds
	raise ArgumentError,
	  "argument to ipc_set must be a Semid_ds"
  end
  check_result(semctl(@semid, 0, IPC_SET, semid_ds))
end

#ipc_statObject Also known as: semid_ds

Return the Semid_ds object. See semctl(2).



264
265
266
267
268
# File 'lib/SysVIPC.rb', line 264

def ipc_stat
  res, semid_ds = semctl(@semid, 0, IPC_STAT)
  check_result(res)
  semid_ds
end

#op(array) ⇒ Object

Perform a set of semaphore operations. The argument array is an Array of Sembuf objects. See semop(2).



292
293
294
# File 'lib/SysVIPC.rb', line 292

def op(array)
  check_result(semop(@semid, array, array.length))
end

#setall(values) ⇒ Object

Set each value in the semaphore set to the corresponding value in the Array values. See semctl(2).



208
209
210
211
212
213
214
# File 'lib/SysVIPC.rb', line 208

def setall(values)
  if values.length > @nsems
	raise ArgumentError,
	  "too many values (#{values.length}) for semaphore set (#{@nsems})"
  end
  check_result(semctl(@semid, 0, SETALL, values))
end

#setval(semnum, val) ⇒ Object

Set the value of semaphore semnum to val. See semctl(2).



227
228
229
# File 'lib/SysVIPC.rb', line 227

def setval(semnum, val)
  check_result(semctl(@semid, semnum, SETVAL, val))
end