Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Determining which processes hold a semaphore Post 302281778 by Corona688 on Thursday 29th of January 2009 12:02:22 PM
Old 01-29-2009
Can't the process itself remember when its used a semaphore before? Sems don't have that kind of memory, they're just counters and a queue. I've written and deleted many solutions here, realizing partway through that they all fail when a process can't remember how many times its locked it already.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

query reg semaphore / processes on solaris

Our Baan application has a server process bflusher which is activated automaticaly by another server process bmanager . These processes uses shared memory to carry out it's operations . Through a baan application query command (tbase6.1 P d 3 ) , i can find the number of users (user process... (1 Reply)
Discussion started by: Hitesh Shah
1 Replies

2. Solaris

Determining processes that have been swapped out

Is there a way to do this in Solaris? For instance, suppose I run the following: $ swap -l swapfile dev swaplo blocks free /dev/md/dsk/d501 85,501 16 16780208 16780208 $ swap -s total: 3377368k bytes allocated + 519416k reserved = 3896784k used, 11011992k available... (1 Reply)
Discussion started by: lyonsd
1 Replies

3. UNIX for Advanced & Expert Users

Monitoring Processes - Killing hung processes

Is there a way to monitor certain processes and if they hang too long to kill them, but certain scripts which are expected to take a long time to let them go? Thank you Richard (4 Replies)
Discussion started by: ukndoit
4 Replies

4. Solaris

Identifying and grouping OS processes and APP processes

Hi Is there an easy way to identify and group currently running processes into OS processes and APP processes. Not all applications are installed as packages. Any free tools or scripts to do this? Many thanks. (2 Replies)
Discussion started by: wilsonee
2 Replies

5. Shell Programming and Scripting

Semaphore

Hi, I am looking to use a semaphore for the first time in one of my scripts. I am just wondering if there are any simple examples or tutorials around? I am a beginner so the simpler the better :) Thanks -Jaken (2 Replies)
Discussion started by: Jaken
2 Replies

6. Shell Programming and Scripting

Hold previous date

A file named abc.txt being updated with date value by one process. Say , today it s updating the file with value 01-09-2009 Fine. Tomorrow the process will override the file with tomorrow date (02-09-2009) .Insome case the process will overriding the file with empty string. So I... (1 Reply)
Discussion started by: Gopal_Engg
1 Replies

7. Programming

Semaphore

In my server code there is a thread per client... The server call accept() and after that start the thread. So there is a thread for client that save in RAM the client's message, that will be send to other clients. Now in RAM I have created a shared memory in which thread read and write(save)... (2 Replies)
Discussion started by: italian_boy
2 Replies

8. Shell Programming and Scripting

Hold buffer in perl

Hi, Can any one tell me is their any "hold buffer" in perl similar to sed. I have to find a pattern, once that pattern found then need to go backward and find another pattern and print. Example: Below are the contents present in a file ## block IPs URLs URL_IPs Unblock URLs ... (4 Replies)
Discussion started by: Anjan1
4 Replies

9. Shell Programming and Scripting

read is not on hold

In end of https://www.unix.com/shell-programming-scripting/103227-while-read-loop-scope-variables-shell.html mjd_tech gives script which can read some values directly without manually input, but if no value is the right one, my understand is, it will on hold for waiting the next input, but when I... (7 Replies)
Discussion started by: newoz
7 Replies

10. Shell Programming and Scripting

Hold buffer in sed

Hi Experts, i have a file like below **** table name is xyz row count for previous day 10 row count for today 20 diff between previous and today 10 scan result PASSED **** table name is abc row count for previous day 90 row count for today 35 diff between previous and today 55... (4 Replies)
Discussion started by: Lakshman_Gupta
4 Replies
sem_timedwait(3C)					   Standard C Library Functions 					 sem_timedwait(3C)

NAME
sem_timedwait, sem_reltimedwait_np - lock a semaphore SYNOPSIS
#include <semaphore.h> #include <time.h> int sem_timedwait(sem_t *restrict sem, const struct timespec *restrict abs_timeout); int sem_reltimedwait_np(sem_t *restrict sem, const struct timespec *restrict rel_timeout); DESCRIPTION
The sem_timedwait() function locks the semaphore referenced by sem as in the sem_wait(3C) function. However, if the semaphore cannot be locked without waiting for another process or thread to unlock the semaphore by performing a sem_post(3C) function, this wait is terminated when the specified timeout expires. The sem_reltimedwait_np() function is identical to the sem_timedwait() function, except that the timeout is specified as a relative time interval. For sem_timedwait(), the timeout expires when the absolute time specified by abs_timeout passes, as measured by the CLOCK_REALTIME clock (that is, when the value of that clock equals or exceeds abs_timeout), or if the absolute time specified by abs_timeout has already been passed at the time of the call. For sem_reltimedwait_np(), the timeout expires when the time interval specified by rel_timeout passes, as measured by the CLOCK_REALTIME clock, or if the time interval specified by rel_timeout is negative at the time of the call. The resolution of the timeout is the resolution of the CLOCK_REALTIME clock. The timespec data type is defined as a structure in the <time.h> header. Under no circumstance does the function fail with a timeout if the semaphore can be locked immediately. The validity of the abs_timeout need not be checked if the semaphore can be locked immediately. RETURN VALUES
The sem_timedwait() and sem_reltimedwait_np() functions return 0 if the calling process successfully performed the semaphore lock operation on the semaphore designated by sem. If the call was unsuccessful, the state of the semaphore is be unchanged and the function returns -1 and sets errno to indicate the error. ERRORS
The sem_timedwait() and sem_reltimedwait_np() functions will fail if: EINVAL The sem argument does not refer to a valid semaphore. EINVAL The process or thread would have blocked, and the timeout parameter specified a nanoseconds field value less than zero or greater than or equal to 1,000 million. ETIMEDOUT The semaphore could not be locked before the specified timeout expired. The sem_timedwait() and sem_reltimedwait_np() functions may fail if: EDEADLK A deadlock condition was detected. EINTR A signal interrupted this function. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Commmitted | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ |Standard |See below. | +-----------------------------+-----------------------------+ For sem_timedwait(), see standards(5). SEE ALSO
semctl(2), semget(2), semop(2), time(2), sem_post(3C), sem_trywait(3C)sem_wait(3C), attributes(5), standards(5) SunOS 5.11 5 Feb 2008 sem_timedwait(3C)
All times are GMT -4. The time now is 11:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy