Sponsored Content
Top Forums Programming help me out with my threaded c++ mudbase - c++, pthread_cond_wait Post 302133670 by porter on Friday 24th of August 2007 03:40:14 PM
Old 08-24-2007
Threads and signals are a bad mix.

In a threaded program you should

(a) have one thread devoted to receiving signals for the process using sigwait, this would then deal with each signal in an orderly manner. This will deal with all signals targetted at the *process*, (SIGINT, SIGQUIT etc). Do a SIG_BLOCK for all these signals in every other thread or before you create those threads so they inherit the signal mask.

(b) set up pthread_cleanup_push/pthread_cleanup_pop to protect each group of local variables to cope with SIGSEGV etc. Set up a single signal handler in the application for SIGSEGV etc that calls pthread_exit(PTHREAD_CANCELLED) or similar.

Also note that some compilers, eg g++ don't destruct C++ objects as they go out of scope during a thread cancellation.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Threaded Discussions for Webpages

Dear All, I run a website for a non-profit. Does anyone know where I can get free or cheap software to run threaded discussions for our website? Our website is obviously running off a unix platform. Thanks (4 Replies)
Discussion started by: evertk
4 Replies

2. Programming

Threaded 'find' utility

I need to modify my version of find in unix and get it to create and use two POSIX threads to carry out concurrent finding operations. How do i get about doing this>? If anyone could help me it would be much appreciated. Thanx Mariuca (1 Reply)
Discussion started by: mariuca
1 Replies

3. Programming

threaded merge sort help

I am working on a merge sort of two files of integers, and am fuzzy on some of the logic\syntax. I need two threads, each of which will open a file, read its contents into an array, and then sort the array using qsort. One thread will operate on file f1.dat(10000 numbers) and leave its sorted... (0 Replies)
Discussion started by: AusTex
0 Replies

4. AIX

multi threaded program is hanging

I have a Multithreaded program which is hanging on AIX. OS Version: AIX 5.2 and thread library version : 5.2.0.75 We Initiate the process with 50 threads..when we are disconnecting from the process it hangs.There is lots of other stuff involved here.I am just sending the piece of the problem with... (0 Replies)
Discussion started by: hikrishn
0 Replies

5. Programming

Conditional wait using pthread_cond_wait() details

Please tell me about internal functionality of pthread_cond_wait(). How it works. Whether it actually put the thread into sleep and do the context switch or use spin locking. (1 Reply)
Discussion started by: mansoorulhaq
1 Replies

6. Shell Programming and Scripting

In need of multi threaded perl assistance

I need to write a perl script to execute external programs and grab the output and return code. Each program should be killed if it has not completed within X seconds. Imagine that the script goes something like this : @commands = &get_commands(); foreach $cmd (@commands) { $pid =... (4 Replies)
Discussion started by: SandmanCL
4 Replies

7. UNIX for Advanced & Expert Users

Multi-threaded encryption @ Fedora 11

Hello, are any of the encryption programs capable of true multi-threading ? Friend of mine tells me that he's been running some testing on Fedora 11 and that the kernel doesn't support multi-threading at that level. I've been looking into TrueCrypt, encfs and both calm to support... (0 Replies)
Discussion started by: TehOne
0 Replies

8. Linux

Multi-threaded encryption @ Fedora 11

Hello, are any of the encryption programs capable of true multi-threading ? Friend of mine tells me that he's been running some testing on Fedora 11 and that the kernel doesn't support multi-threading at that level. I've been looking into TrueCrypt, encfs and both calm to support... (1 Reply)
Discussion started by: TehOne
1 Replies

9. Programming

multi-threaded memory leak

Hello All : I write a .c program to test the exactually resource the memory leak as follows: 1 #include <stdio.h> 2 #define NUM 100000 3 void *Thread_Run(void * arg){ 4 //TODO 5 //pthread_datch(pthread_self()); 6 int socket= (int)arg; 7 ... (1 Reply)
Discussion started by: aobai
1 Replies

10. Shell Programming and Scripting

Need threaded python script

I have a single threaded bash script that I am using to create secgroup rules in openstack. The process to add the rules is taking forever. Any of you python gurus know how to convert this bash script into a thread python script? Thanks in advanced. create-secgroup-rules.sh: #!/bin/bash cat ... (2 Replies)
Discussion started by: stovie1000
2 Replies
ldi_putmsg(9F)						   Kernel Functions for Drivers 					    ldi_putmsg(9F)

NAME
ldi_putmsg, ldi_getmsg - Read/write message blocks from/to a stream SYNOPSIS
#include <sys/sunldi.h> int ldi_putmsg(ldi_handle_t lh, mblk_t *smp); int ldi_getmsg(ldi_handle_t lh, mblk_t **rmp, timestruc_t *timeo); PARAMETERS
lh Layered handle. smp Message block to send. rmp Message block to receive. timeo Optional timeout for data reception. DESCRIPTION
The ldi_putmsg function allows a caller to send a message block to a streams device specified by the layered handle lh. Once the message (smp) has been passed to ldi_putmsg(), the caller must not free the message even if an error occurs. The ldi_getmsg() function allows a caller to receive a message block from a streams device specified by the layered handle lh. Callers must free the message received with freemsg(9F). If a NULL timeout value is specified when the caller receives a message, the caller sleeps until a message is received. RETURN VALUES
The ldi_putmsg() and ldi_getmsg() functions return 0 upon success. If a failure occurs before the request is passed to the device, the pos- sible return values are shown below. Otherwise any other error number may be returned by the device. EINVAL Invalid input parameters. ENOTSUP Operation is not supported for this device. The ldi_getmsg() function may also return: ETIME Returned if the timeout timeo expires with no messages received. CONTEXT
These functions may be called from user or kernel context. SunOS 5.11 3 June 2003 ldi_putmsg(9F)
All times are GMT -4. The time now is 02:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy