A scoreboard is a set of integer numbers residing in shared memory. It is organized as 2-dimensional array where a line in one of the dimensions is called a slot. So, in other words the scoreboard is a set of slots and each slot is a set of integer numbers.
The idea is that in a system of processes or threads of execution each process owns a slot. A process can change the values in its own slot at will but must adhere to read-only access to other slots.
There is one extra slot at the end of the scoreboard that is allowed to be used by every process. However the IPC::ScoreBoard module does not provide any kind of locking to synchronize access.
The extra slot can differ in size from the other normal slots.
A scoreboard can be anonymous or it can have a name in the file system and hence be accessed by unrelated processes.
SYNOPSIS
use IPC::ScoreBoard;
# create an anonymous scoreboard
my $sb=SB::anon $nslots, $slotsize, $extra;
# create a file base board
my $sb=SB::named $filename, $nslots, $slotsize, $extra;
# open a file based board
my ($sb, $nslots, $slotsize, $extra)=SB::open $filename;
# set/set a value
SB::set $sb, $slotidx, $elidx, $integer_value;
$value=SB::get $sb, $slotidx, $elidx;
@values=SB::get_all $sb, $slotidx;
# increment/decrement
SB::incr $sb, $slotidx, $elidx, $integer_value;
SB::decr $sb, $slotidx, $elidx, $integer_value;
# sum functions
$sum=SB::sum $sb, $elidx;
@sums=SB::sum_all $sb;
# access extra space
SB::set_extra $sb, $elidx, $integer_value;
$value=SB::get_extra $sb, $elidx;
@values=SB::get_all_extra $sb;
SB::incr_extra $sb, $elidx, $integer_value;
SB::decr_extra $sb, $elidx, $integer_value;
# fetch parameters
$nslots=SB::nslots $sb;
$slotsize=SB::slotsize $sb;
$nextra=SB::nextra $sb;
# does the compiler provide atomic increment/decrement operations?
if( SB::have_atomics ) {
# increment and decrement operations are atomic
}
Product's homepage
Requirements:
· Perl