OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [unix/] [posix/] [tools/] [semdump.in] - Blame information for rev 493

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
#!@PERL@
2
#
3
#  $Id: semdump.in,v 1.2 2001-09-27 12:01:15 chris Exp $
4
#
5
eval "exec @PERL@ -S $0 $*"
6
    if $running_under_some_shell;
7
 
8
# dump semaphore array values   tony@divnc.com
9
 
10
require 'sys/sem.ph';
11
require 'getopts.pl';
12
&Getopts("vhi:k:");               # verbose, help, id, key
13
 
14
if ($opt_h || ($opt_i && $opt_k))
15
{
16
    print STDERR <
17
semdump
18
 
19
    Dump info about specified semaphore.
20
 
21
Usage: $0       [-v] { -i semid | -k semkey }
22
 
23
    -v          -- possibly more verbose
24
    -i semid    -- semaphore id
25
    -k semkey   -- semaphore key
26
    -h          -- help
27
 
28
    anything else == this help message
29
NO_MORE_HELP
30
    exit 1;
31
}
32
 
33
$verbose = $opt_v;
34
$id = $opt_i;
35
$key = $opt_k;
36
 
37
if ($key)
38
{
39
    $key = oct($key) if $key =~ /^0/;
40
    die "Could not convert key to id; $!" unless $id = semget($key, 1, 0);
41
}
42
 
43
# I don't know to find out how many sem's are attached to the id
44
#  so just keep reading them until we get an error.
45
 
46
printf("KEY: 0x%X (%d)  ", $key, $key) if $key;
47
print "ID: $id\n";
48
 
49
semlist:
50
for ($semnum=0; $semnum < 10; $semnum++)
51
{
52
    $val = semctl($id, $semnum, &GETVAL, 0);
53
    $val || ($val = -1);
54
 
55
    last semlist if ($val == -1);
56
 
57
    printf " %d: %d\n", $semnum, $val;
58
}
59
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.