Sponsored Content
Full Discussion: Signalsafe data structures
Top Forums Programming Signalsafe data structures Post 302579829 by littlegnome on Tuesday 6th of December 2011 06:13:57 PM
Old 12-06-2011
Signalsafe data structures

Hello,

I have a signal handler which manipulates a data structure. The data structure's operations aren't atomic. So if two threads/processes are in a critical section at the same time the data structure will be broken.

With threads you can avoid this stuff with semaphores etc.
However, signal handlers work a bit different than threads. If a signal handler is currently manipulating the data structure and during this the signal handler is called again, then the following happens:

It cannot access the data structure because the first signal handler has it locked, which results in a deadlock.

How can I avoid it but still manipulate my data structure? I cannot lose signals either.
 

3 More Discussions You Might Find Interesting

1. Programming

Recommendations For Generic C Data Structures & Algorithms

Hi All, Rather than re-invent the wheel, I am trying to find a mature C library that provides generic support for lists, trees, etc. I understand C doesn't formally support "generics", but am aware of a few solutions like GLib and SGLib. Can anyone kindly recommend what they think is best?... (1 Reply)
Discussion started by: tristan12
1 Replies

2. Programming

shared memory - userdefined data structures

Hello, I wonder if I can write my userdefined data structures(ex: a list) to a shared memory segment? I know, the shm functions get (void*) parameter so I should be able to read and write a list into the shared memory. may someone inform and clarify me about that, please? (1 Reply)
Discussion started by: xyzt
1 Replies

3. Shell Programming and Scripting

Perl Data Structures

Here is what i need to do. @data #has all column wise data so say info for col 1 location for all rows would be in this array $array = \@data But i need to create a file which should contain these information in a format for all columns even if i have got no values from some of the index... (0 Replies)
Discussion started by: dinjo_jo
0 Replies
ARRAY_REPLACE(3)							 1							  ARRAY_REPLACE(3)

array_replace - Replaces elements from passed arrays into the first array

SYNOPSIS
array array_replace (array $array1, array $array2, [array $...]) DESCRIPTION
array_replace(3) replaces the values of $array1 with values having the same keys in each of the following arrays. If a key from the first array exists in the second array, its value will be replaced by the value from the second array. If the key exists in the second array, and not the first, it will be created in the first array. If a key only exists in the first array, it will be left as is. If several arrays are passed for replacement, they will be processed in order, the later arrays overwriting the previous values. array_replace(3) is not recursive : it will replace values in the first array by whatever type is in the second array. PARAMETERS
o $array1 - The array in which elements are replaced. o $array2 - The array from which elements will be extracted. o $... - More arrays from which elements will be extracted. Values from later arrays overwrite the previous values. RETURN VALUES
Returns an array, or NULL if an error occurs. EXAMPLES
Example #1 array_replace(3) example <?php $base = array("orange", "banana", "apple", "raspberry"); $replacements = array(0 => "pineapple", 4 => "cherry"); $replacements2 = array(0 => "grape"); $basket = array_replace($base, $replacements, $replacements2); print_r($basket); ?> The above example will output: Array ( [0] => grape [1] => banana [2] => apple [3] => raspberry [4] => cherry ) SEE ALSO
array_replace_recursive(3), array_merge(3). PHP Documentation Group ARRAY_REPLACE(3)
All times are GMT -4. The time now is 06:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy