Sponsored Content
Full Discussion: Atomicity
Top Forums Programming Atomicity Post 50800 by S.P.Prasad on Monday 3rd of May 2004 02:02:58 AM
Old 05-03-2004
Atomicity

I am working on a primitive project ported on AIX Unix Box. Earlier this system used to run on VMS VAX and DEC Alpha system. The major source code files are written in FROTRAN.

Across process data are exchanged through FROTRAN COMMONS and a specific locking mechanism is implemented for resource synchronization. Data for exchange are stored in FROTRAN Array in COMMONS. During addition to the bottom of the array and removal from the top, a specific position of the array is marked as 1 or 0 meaning that array can be accessed or cannot. Based upon these values the action on arrays would be taken. I hope that I am clear.

They used LIB$BBSSI() system call to lock the list and LIB$BBCCI() system call to release the list from lock state in VMS. I presume that this would be atomic cause of which process where in synchronization.

During porting of the same software in Tru64 they swapped the same routines with C subroutines _TESTBITSSI() and _TESTBITCCI() calls.

The problem came when they ported it to AIX. Due to lack of technology specifications we are unable to have atomic locking mechanism. Hence the issue is that two or more process is able to detect that they can act on a same array resulting on an unpredictable behavior.

We need a solution for the problem. I though of a solution but I don't know that in multi-process environment whether the solution would work or not. Please provide your necessary input and ensure that the code does leads to a DEADLOCK.
:

During the process startup we would store the required address our interest. Say for example we have 3-array list and list lock index is 1. So if the arrays are named as A, B, D then we will store the address of A (1), B (1) and D (1) in ‘C' array of pointers *list_arr[3] (list_arr[0], list_arr[1], list_arr[2]).
Now LOCK() and REL() subroutine would be called across process running in different address space.

LOCK(int *bit_pos, int *address)
{
.......
.......
/* For One specific address */
RERUN:
if ( address == list_arr[0] )
{
if ( shared_variable_One == 0 ) /* Variable Shared Across Processes */
{
shared_variable_One = getpid ( ) ;
}
if (shared_variable_One == getpid ( ) )
{
if ( ++ shared_variable_two > 1 ) /* Variable Shared Across Processes Initially initialized as 0*/
goto RERUN:
/* Set the bit value */
shared_variable_One = 0 ;
shared_variable_two = 0 ;
}
else
goto RERUN;
}

.......................
.......................
}
The same can be implemented for REL(int *bit_pos, int *address).

These subroutines would then be called through FROTANS subroutines.

I have had thought about using SEMAPHORES but then we had to use 3 semaphores (as in this example) such that operation on one address by one process does not blocks operation on other address which is being accessed by multiple process.

Thanks in advance.

Last edited by S.P.Prasad; 05-03-2004 at 03:34 AM..
 
Graphics::Primitive::Driver::Cairo(3pm) 		User Contributed Perl Documentation		   Graphics::Primitive::Driver::Cairo(3pm)

NAME
Graphics::Primitive::Driver::Cairo - Cairo backend for Graphics::Primitive VERSION
version 0.44 SYNOPSIS
use Graphics::Primitive::Component; use Graphics::Primitive::Driver::Cairo; my $driver = Graphics::Primitive::Driver::Cairo->new; my $container = Graphics::Primitive::Container->new( width => 800, height => 600 ); my $black = Graphics::Primitive::Color->new(red => 0, green => 0, blue => 0); $container->border->width(1); $container->border->color($black); $container->padding( Graphics::Primitive::Insets->new(top => 5, bottom => 5, left => 5, right => 5) ); my $comp = Graphics::Primitive::Component->new; $comp->background_color($black); $container->add_component($comp, 'c'); my $lm = Layout::Manager::Compass->new; $lm->do_layout($container); my $driver = Graphics::Primitive::Driver::Cairo->new( format => 'PDF' ); $driver->draw($container); $driver->write('/Users/gphat/foo.pdf'); DESCRIPTION
This module draws Graphics::Primitive objects using Cairo. IMPLEMENTATION DETAILS
Borders Borders are drawn clockwise starting with the top one. Since cairo can't do line-joins on different colored lines, each border overlaps those before it. This is not the way I'd like it to work, but i'm opting to fix this later. Consider yourself warned. ATTRIBUTES
antialias_mode Set/Get the antialias mode of this driver. Options are default, none, gray and subpixel. cairo This driver's Cairo::Context object format Get the format for this driver. surface Get/Set the surface on which this driver is operating. METHODS
data Get the data in a scalar for this driver. write ($file) Write this driver's data to the specified file. get_text_bounding_box ($font, $text, $angle) Returns two Rectangles that encloses the supplied text. The origin's x and y maybe negative, meaning that the glyphs in the text extending left of x or above y. The first rectangle is the bounding box required for a container that wants to contain the text. The second box is only useful if an optional angle is provided. This second rectangle is the bounding box of the un-rotated text that allows for a controlled rotation. If no angle is supplied then the two rectangles are actually the same object. If the optional angle is supplied the text will be rotated by the supplied amount in radians. get_textbox_layout ($tb) Returns a Graphics::Primitive::Driver::TextLayout for the supplied textbox. reset Reset the driver. draw Draws the specified component. Container's components are drawn recursively. ACKNOWLEDGEMENTS
Danny Luna AUTHOR
Cory G Watson <gphat@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Cold Hard Code, LLC. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.12.4 2011-09-27 Graphics::Primitive::Driver::Cairo(3pm)
All times are GMT -4. The time now is 07:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy