Sponsored Content
Top Forums Programming Getting errno in a Multithreaded program Post 12432 by S.Vishwanath on Monday 31st of December 2001 03:09:25 AM
Old 12-31-2001
Getting errno in a Multithreaded program

In Tru64 Unix, the 'errno' variable is not thread safe.
Could anybody help me about how to make it thread safe or how to check 'errno' in a Multithreaded program ????

The Programming process is like this.

There are some definite number of threads having their own task.
There is one particular thread which tries to read from Disk.
We know that there can be n-number of possibilities for a read to fail. So, depeinding upon the error number thrown from a read failure., I call appropriate thread to take some action .

This task works fine when implemented as a Monolithic Program (i.e., non-multi threaded approach) but since my program is a multithreaded I'm not able to get the appropriate error no. as it is not thread safe.

So, can any body help me out with some technic/method of getting/traping out the appropriate errno.

Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Programming

errno pb

Hello, I need to make a lib with pthread, when I run my make file all is good. But when I run my test program, I test errno in the begining and is already set to 251. Is it normal ??? What can I modify in my Makefile to have errno set to 0 ??? Thanks $make gcc -D_REENTRANT -shared -fpic... (3 Replies)
Discussion started by: dts
3 Replies

2. Programming

Hi errno in sys/stat.h

How should I use errno in a c program and what info does it have . I am working with directories and files. So can any one tell me How to access errno?I am using the stat() function on \etc directory and I am alble to access only the half of the directories.I am not able to access other half and... (6 Replies)
Discussion started by: vijlak
6 Replies

3. Linux

getting problem in my code:::: plz help...(multithreaded appn with serial comm.)

hello, here I am copying my code... I am using two threads for reading and writing at com ports....one for reading and one for writing...in read thread I am using select() api....and polling again and again if there is some data to be read....but select is not returning any positive value so... (0 Replies)
Discussion started by: arunchaudhary19
0 Replies

4. Programming

getting problem in my code:::: plz help...(multithreaded appn with serial comm.)

hello, here I am copying my code... I am using two threads for reading and writing at com ports....one for reading and one for writing...in read thread I am using select() api....and polling again and again if there is some data to be read....but select is not returning any positive value so... (0 Replies)
Discussion started by: arunchaudhary19
0 Replies

5. Programming

errno

Hey, Can I assume that for certain function calls, errno can never be set to a certain value. More specifically, can I assume that for if the stat function call fails, the errno can never be or "No space left on device." I am assuming that a read function cannot fail because of no space... (5 Replies)
Discussion started by: the_learner
5 Replies

6. Shell Programming and Scripting

execute command multithreaded util without programming

Hello all is there any way in unix to execute command in multithreaded way without doing it in java or cpp can one of the scripts handle multithread execution ? i need to test server requests ( corba ) in multithread Thanks (0 Replies)
Discussion started by: umen
0 Replies

7. UNIX for Advanced & Expert Users

forking in multithreaded program

hi all, i am using pthreads. What will happen if a thread does a fork? will all the threads are duplicated for the new process or only the called thread is duplicated? are the resources shared across the processes? thank you (0 Replies)
Discussion started by: skyrulz
0 Replies

8. Programming

Basic multithreaded program

I'd like to write a program (I'm flexible on language; C/C++ was my original idea but a scripting language would probably be better) that runs hundreds of programs, but only N = 4 (say) at a time. The idea is to keep all the cores on a multicore machine busy. How can I do this? In particular,... (6 Replies)
Discussion started by: CRGreathouse
6 Replies

9. Programming

does perror() set errno?

here the program gives a odd result: #include <stdio.h> int main(){ perror("first"); perror("next"); return 0; } result: first: Success next: Illegal seek why? any resonable explanation? i found no information about this in man pages. thanks in advance (2 Replies)
Discussion started by: ebd
2 Replies

10. AIX

Errno.h symbols

Hi, I need to look at a recent copy of /usr/include/errno.h from AIX 7.2 to check some symbols. In particular, I'm curious if it defines EOWNERDEAD and ENOTRECOVERABLE. Can someone who has access to 7.2 please check for me? Thanks! (1 Reply)
Discussion started by: topcat
1 Replies
pthread_resume_np(3T)													     pthread_resume_np(3T)

NAME
pthread_resume_np(), pthread_continue(), pthread_suspend() - resume execution of a thread, continue execution of a thread, and suspend exe- cution of a thread SYNOPSIS
PARAMETERS
thread whose execution is to be suspended or resumed. flags Flags to be used by The valid values are: The target thread's suspension count is decremented by one. If the target thread was suspended and has a suspend count greater than one, the thread will not resume execution. The target thread's suspension count is set to zero. The target will resume execution even if its suspend count was greater than one. DESCRIPTION
The function suspends execution of the target thread specified by thread. The target thread may not be suspended immediately (at that exact instant). On successful return from the function, thread is no longer executing. Once a thread has been suspended, subsequent calls to the function increment a per thread suspension count and return immediately. Calling with the calling thread specified in thread is allowed. Note that in this case the calling thread shall be suspended during execu- tion of the function call and shall only return after another thread has called the or function for thread. The function resumes the execution of the target thread thread. If thread was suspended by multiple calls to only one call to is required to resume the execution of thread. Calling for a target thread that is not suspended shall have no effect and return no errors. Calling is equivalent to calling with the flags parameter specified as The function resumes the execution of the target thread specified by thread. If the flags argument is the target thread's suspension count is decremented by one. If the flags argument is the target thread's suspension count is set to zero. When the target thread's suspension count reaches zero, the target thread is allowed to continue execution. Calling for a target thread that is not suspended shall have no effect and return no errors. WARNING
This warning is applicable if any of the following conditions is true for a threaded application: a. The or environment variable is set to either or b. The application's binary is brought forward from a HP-UX 11i v1 release. In either of the above conditions, it is strongly recommended to set the environment variable to if the application uses which is not POSIX compliant. Failing to do so, can lead to undefined behavior. RETURN VALUE
If successful, and return zero. Otherwise, an error number shall be returned to indicate the error (the variable is not set). ERRORS
If any of the following occur, the function returns the corresponding error number. [ESRCH] The target thread thread is not in the current process. [EDEADLK] The target thread thread is the last running thread in the process. The operation would result in deadlock for the process. If any of the following occur, the and functions return the corresponding error number. [ESRCH] The target thread thread is not in the current process. [EINVAL] The value specified by flags is invalid. APPLICATION USAGE
This functionality enables a process that is multithreaded to temporarily suspend all activity to a single thread of control. When the process is single threaded, the address space is not changing, and a consistent view of the process can be gathered. One example of its use is for garbage collecting. The garbage collector runs asynchronously within the process and assumes that the process is not changing while it is running. Suspending a thread may have adverse effects on an application. If a thread is suspended while it holds a critical resource, such as a mutex or a read-write lock, the application may stop or even deadlock until the thread is continued. While the thread is suspended, other threads which may contend for the same resource must block until the thread is continued. Depending on application behavior, this may even result in deadlock. Application programmers are advised to either a) only suspend threads which call async-signal safe functions or b) ensure that the suspending thread does not contend for the same resources that the suspended thread may have acquired. Note: this includes resources that may be acquired by libraries. The and functions cannot reliably be used for thread synchronization. Synchronization primitives like mutexes, semaphores, read-write locks, and condition variables should be used instead. AUTHOR
and were developed by X/Open. was developed by HP. SEE ALSO
pthread_create(3T). STANDARDS CONFORMANCE
Pthread Library pthread_resume_np(3T)
All times are GMT -4. The time now is 05:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy