Sponsored Content
Top Forums Programming pthread_mutex_timedlock and Timers option Post 302457710 by ramestica on Tuesday 28th of September 2010 03:47:56 PM
Old 09-28-2010
I see. So, the sole presence in my environment of functions like clock_gettime should suggest to me that the 'Timers option' is actually available indeed and, therefore, something like this:

clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += 1;

it should work as a one second timeout on pthread_mutex_timedlock. But well, this is exactly what did not work for me (timeout in much less than a second) and the 'Timers option' thing started to call my attention.

I will revisit my implementation here and eventually come back with actual test code for more help :-)

many thanks,
Rodrigo
 

10 More Discussions You Might Find Interesting

1. Programming

unix and timers

Hello there.. I need to know when i start indipendant timers how can i recognize which of the active timers have made timeout alarm. The number of started timers depends on the running app I'd appreciate your help Thanks in advance (0 Replies)
Discussion started by: nightcat
0 Replies

2. UNIX for Advanced & Expert Users

-h option

Hi what does the following mean in shell scripts (-h option) val contains a string. while (-h "$val") (1 Reply)
Discussion started by: Raom
1 Replies

3. UNIX for Advanced & Expert Users

su option

We have started to us the su option on our production server. We log in with our own id and then su into a special id to perform various tasks. This allows our actions to be monitored. I need to know how to use the su option when doing an ftp between two servers. I noticed that when I log into... (1 Reply)
Discussion started by: lesstjm
1 Replies

4. Programming

cc option

my yacc output file y.tab.c is not compiling using cc y.tab.c -ly command .possibily option flag -ly is not correct.i m using red hat linux 9.please give solutions. (4 Replies)
Discussion started by: kuldeep_bora
4 Replies

5. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies

6. Programming

Doubts about timers in linux kernel

Hi , I am trying to learn timers in linux kernel. I am trying to write a program where I can configure a timer to tick in every 5 seconds and a function should thus exicute in every five seconds. I tried one program with the help of linux/timer.h headerfile but I couldnt get the... (4 Replies)
Discussion started by: iamjayanth
4 Replies

7. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

8. Shell Programming and Scripting

A Question Regarding Timers and Output

Hi there. I am fairly new to scripting in BASH so please forgive my clumsy syntax and analogy as I try to explain what I am trying to accomplish. I have a list of mundane functions that I currently call from a script file. What I wish to do is to accurately record into a log file the times that... (17 Replies)
Discussion started by: Tenuous
17 Replies

9. Shell Programming and Scripting

-f option and -rf in rm

Hi, I'm new to shell scripting and I'm trying to read some code I need to use. Could you help me out on what it's doing? I read this as.... if the directory has files then rm all the files in that directory. I'm not sure.... if ; then run "rm -rf ${TSP_FILEPATH_PLUGIN_DIR}"; fi run... (8 Replies)
Discussion started by: jdilts
8 Replies

10. Solaris

Unrecognized option: sparc-sun-Solaris2.10/bin/as: unrecognized option `-m32'

Hi, I installed some packages required by an app built with python. But when I try python setup.py install, I get the following error: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32' Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies
PTHREAD_MUTEX_TIMEDLOCK(3P)				     POSIX Programmer's Manual				       PTHREAD_MUTEX_TIMEDLOCK(3P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
pthread_mutex_timedlock - lock a mutex (ADVANCED REALTIME) SYNOPSIS
#include <pthread.h> #include <time.h> int pthread_mutex_timedlock(pthread_mutex_t *restrict mutex, const struct timespec *restrict abs_timeout); DESCRIPTION
The pthread_mutex_timedlock() function shall lock the mutex object referenced by mutex. If the mutex is already locked, the calling thread shall block until the mutex becomes available as in the pthread_mutex_lock() function. If the mutex cannot be locked without waiting for another thread to unlock the mutex, this wait shall be terminated when the specified timeout expires. The timeout shall expire when the absolute time specified by abs_timeout passes, as measured by the clock on which timeouts are based (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. If the Timers option is supported, the timeout shall be based on the CLOCK_REALTIME clock; if the Timers option is not supported, the time- out shall be based on the system clock as returned by the time() function. The resolution of the timeout shall be the resolution of the clock on which it is based. The timespec data type is defined in the <time.h> header. Under no circumstance shall the function fail with a timeout if the mutex can be locked immediately. The validity of the abs_timeout param- eter need not be checked if the mutex can be locked immediately. As a consequence of the priority inheritance rules (for mutexes initialized with the PRIO_INHERIT protocol), if a timed mutex wait is ter- minated because its timeout expires, the priority of the owner of the mutex shall be adjusted as necessary to reflect the fact that this thread is no longer among the threads waiting for the mutex. RETURN VALUE
If successful, the pthread_mutex_timedlock() function shall return zero; otherwise, an error number shall be returned to indicate the error. ERRORS
The pthread_mutex_timedlock() function shall fail if: EINVAL The mutex was created with the protocol attribute having the value PTHREAD_PRIO_PROTECT and the calling thread's priority is higher than the mutex' current priority ceiling. EINVAL The process or thread would have blocked, and the abs_timeout parameter specified a nanoseconds field value less than zero or greater than or equal to 1000 million. ETIMEDOUT The mutex could not be locked before the specified timeout expired. The pthread_mutex_timedlock() function may fail if: EINVAL The value specified by mutex does not refer to an initialized mutex object. EAGAIN The mutex could not be acquired because the maximum number of recursive locks for mutex has been exceeded. EDEADLK The current thread already owns the mutex. This function shall not return an error code of [EINTR]. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
The pthread_mutex_timedlock() function is part of the Threads and Timeouts options and need not be provided on all implementations. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
pthread_mutex_destroy(), pthread_mutex_lock(), pthread_mutex_trylock(), time(), the Base Definitions volume of IEEE Std 1003.1-2001, <pthread.h>, <time.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 PTHREAD_MUTEX_TIMEDLOCK(3P)
All times are GMT -4. The time now is 03:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy