Linux-Development-Sys Digest #607, Volume #8      Wed, 4 Apr 01 00:13:11 EDT

Contents:
  Re: pthread - threads and semaphores - help! (Philip Armstrong)
  Re: signed vs unsigned ints discussion please (Ulrich Weigand)
  Re: Win Modems (Johan Kullstam)
  Re: Equivalent function to IRIX hinv? (Robert Lynch)
  CDR to Scsi (Stuart)
  Re: TCP/IP socket buffering (David Schwartz)
  Re: HELP!!! Why does this crash the kernel (David Schwartz)
  Re: setsockopt() return "protcol not available" please help (David Schwartz)
  Re: Shared libs and memory usage (David Schwartz)
  Re: /etc/init.d/function:daemon() (David Schwartz)
  Re: How to call a function and don't wait for return (David Schwartz)
  Re: cpu scheduling problem (David Schwartz)
  KERNEL PANIC on Mandrake 7.2 (Noe Nieto)
  Re: did anyone have problems with Daylight Savings changeover? (Rick Ace)
  Re: How to read/write kernel addr, say c0101000? (Gu Weining)
  Re: CDR to Scsi (David Efflandt)

----------------------------------------------------------------------------

From: [EMAIL PROTECTED] (Philip Armstrong)
Subject: Re: pthread - threads and semaphores - help!
Date: 3 Apr 2001 18:59:57 +0100

In article <[EMAIL PROTECTED]>,
Ivor Cox <[EMAIL PROTECTED]> wrote:
>1. I am not sure if I need special compile flags for multi-thread
>(reentrant)

You need -D_REENTRANT I believe. See below.

>3. I need a recursive semaphore and 'man' documentation seems to support
>this. However the compile will not work as the recursive bits of the header
>are conditional on __USE_GNU. I can't set this, it seems, unless I copy the
>header and edit it (as an experiment - this can't be expected to be right.)

Read /usr/include/features.h

>Can anyone advise me - I am a linux newbie - on the basics for threads in
>linux. I understand threads in principle and have a working app for
>win/neutrino - I need to know the basics for linux re recursive semahores
>and compiler options etc for multi-thread.
>
>(I do read the documentation, but it does not always stack!)

:) The docs are of course spread in various places. However, for the
purpose of propramming threaded apps, you should check out the libc
docs on the subject. They should already be installed; try 

 $ info libc

cheers,

Phil

-- 
http://www.kantaka.co.uk/ .oOo. public key: http://www.kantaka.co.uk/gpg.txt


------------------------------

From: [EMAIL PROTECTED] (Ulrich Weigand)
Subject: Re: signed vs unsigned ints discussion please
Date: 3 Apr 2001 22:44:58 +0200

"Gene Heskett" <[EMAIL PROTECTED]> writes:

>I'm trying to clean up some c++ code but don't know a lot about c++.  One
>of the problems in this code is that there are many places in it where
>the format is:

>  if var >= 0

>where the var is an int and isn't spec'd as an unsigned, and in fact
>can't be or the compiler bails out totally since such a comparison is
>always true.  I actually tried that :(

>So the real problem is that the casting of the numeral '0' must be an
>unsigned value according to the warnings given.

Well, it would help if you'd actually tell us what the problem is ;-)
A comparison 'if (var >= 0)' where var is a (signed) int is 
perfectly fine, and should not produce any warnings ...

[ Just 'int' is the same as 'signed int' b.t.w.    Literal constants
are also by default interpreted as of type 'signed int', unless it would 
fall out of the allowed range or you specifically add a suffix of 'U'. ]

>The question then is:  How can I specify, in c++, a globally available
>signed int containing the value of zero, or 0x80000000?  Then all I have
>to do is change all the '0's to 'zero'.

The bit pattern 0x80000000 denotes either 2147483648 (if interpreted
as unsigned int) or -2147483648 (if interpreted as signed int); under
no circumstances does it denote the integer 0.  [ This assumes your
machine is using 32-bit words and two-complement number representation
as e.g. Intel does. ]

To define a variable 'zero' that holds the value 0, you'd just do
   int zero = 0;
I have no idea what the point of this would be, though ;-)

-- 
  Dr. Ulrich Weigand
  [EMAIL PROTECTED]

------------------------------

Crossposted-To: 
alt.computer.drivers,alt.os.linux,aus.computers.linux,comp.os.linux.development.apps,comp.os.linux.hardware
Subject: Re: Win Modems
From: Johan Kullstam <[EMAIL PROTECTED]>
Date: 03 Apr 2001 16:59:58 -0400

"LittleFish" <littlefish_au[SPAM ME AT YOUR OWN RISK]@yahoo.com> writes:

> It seems as if more and more people using Windows
> are very dissapointed over the performance of there Lucent Winmodems. In the
> last week I have met 3 people that have taken back there Lucent Winmodem
> because it drops out regularly. If your machine is slower 300Mhz or is
> running a CPU intensive task in the background you can bet that it will drop
> out. Give me a real modem anyday!! By the way real internal modems are
> getting hard to source. Does anyone have suggestions for a Internal Fax
> Voice Data modem?

one word _EXTERNAL_.  yes, i know you said internal but why not expand
your possibilities?  since most mice these days are ps/2 or usb, you
probably have nothing on your rs232 ports.  why not use it?

-- 
J o h a n  K u l l s t a m
[[EMAIL PROTECTED]]
sysengr

------------------------------

From: Robert Lynch <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Subject: Re: Equivalent function to IRIX hinv?
Date: Tue, 03 Apr 2001 14:11:26 -0700

"Carden, C. (Chris)" wrote:
> 
> Can anyone point me to a way or ways to get a hardware inventory from
> Linux?  I'm stuck in a dungeon without documentation.
> 
> IRIX has a nice function, called hinv, which produces a listing like
> this:
> 
> > 1 400 MHZ IP30 Processor
[snip-rest of inventory]
> Any ideas would be appreciated.  Thanks in advance.
> --
> Chris Carden
> Software Engineer
> Certified Maya Instructor
> Alias|Wavefront, Inc.
> 
> [EMAIL PROTECTED]
> (248) 521-0676

Some time back, someone (not me, it's NOT mine) posted this Perl
script:
==
#!/usr/bin/perl -w
use strict;

# hinv.pl - take hardware inventory
# Note: one thing I did not check in this script is
# the efficiency of the regex's.  So if they are lack-
# ing, don't blame me. ;-]

# Declare global variables. :-(
# Some of these can probably have their
# scope localized (or maybe not).

use vars qw
[
    %fdc      %cpus $mem $speed $scsi $eth
    %ttys     @eth  $hda $hdb   $hdc  $hdd
    %graphics $kbd  $tmr $ides  $ppt 
    %floppy
];

open(DMESG, 'dmesg |')
    || die "Can't fork dmesg: $!\n";

# dmesg seems like an ugly way to do this,
# this information has got to be laying around
# in the filesystem somewhere.

while (my $line = <DMESG>) {
    chomp($line);
    my @fields = split(/\s+/, $line);

    if ($line =~ /^tty/) {
        $ttys{$fields [-1]} ++;
    }
    elsif ($line =~ /^Floppy/) {
        $floppy{$fields [-1]} ++;
    }
    elsif ($line =~ /^FDC /) {
        $line =~ s~.*is a ~~;
        $fdc{$line} ++;
    }
    elsif ($line =~ /^scsi : detected /) {
        $scsi = $line;
    }
    elsif ($line =~ /^eth\d+.* at /) {
        $line =~ s~\s*at .*~~;
        push(@eth, $line);
    }
}

close(DMESG);

open(CPU, '/proc/cpuinfo')
    || die "Can't read /proc/cpuinfo: $!\n";

# Get some information about our CPU(s).

while (my $line = <CPU>) {
    chomp($line);
    my @fields = split(/\s+/, $line);

    if ($line =~ /cpu MHz/) {
        $speed = $fields [3];
    }
    elsif ($line =~ /vendor_id/) {
        my $vendor = $fields [2];
        $cpus{$vendor} ++;
    }
}

close(CPU);

open(IO, '/proc/ioports')
    || die "Can't read /proc/ioports: $!\n";

# Check for keyboard, graphics card, and timer.

while (my $line = <IO>) {
    chomp($line);

    if ($line =~ /keyboard/) {
        $kbd ++;
    }
    elsif ($line =~ /vga/) {
        my @fields = split(/\s+/, $line);
        $graphics{$fields [-1]} ++;
    } 
    elsif ($line =~ /timer/) {
        $tmr ++;
    }
}

close(IO);

# Get system memory information.

open(MEM, '/proc/meminfo')
    || die "Can't read /proc/meminfo: $!\n";

while (my $line = <MEM>) {
    chomp($line);
    my @fields = split(/\s+/, $line);

    if ($line =~ /^MemTotal: /) {
        use integer;
        $fields [1] /= 1024;
        $mem = "Total memory: ~$fields[1]M\n";
    }
}

close(MEM);

# Check for /dev/hda .. /dev/hdd (IDE devices)
# This is probably a bad way to do this, a for
# loop could probably automate the check to see
# how many disk devices we have.  This fails for
# /dev/hde, so it is not very scalable.

if (-e '/proc/ide/hda/model') {
    open(HDA, '/proc/ide/hda/model')
        || die "Can't read /proc/ide/hda/model: $!\n";
    $hda = <HDA>;
    $ides ++;
    close(HDA);
}
if (-e '/proc/ide/hdb/model') {
    open(HDB, '/proc/ide/hdb/model')
        || die "Can't read /proc/ide/hdb/model: $!\n";
    $hdb = <HDB>;
    $ides ++;
    close(HDB);
}
if (-e '/proc/ide/hdc/model') {
    open(HDC, '/proc/ide/hdc/model')
        || die "Can't read /proc/ide/hdc/model: $!\n";
    $hdc = <HDC>;
    $ides ++;
    close(HDC);
}
if (-e '/proc/ide/hdd/model') {
    open(HDD, '/proc/ide/hdd/model')
        || die "Can't read /proc/ide/hdd/model: $!\n";
    $hdd = <HDD>;
    $ides ++;
    close(HDD);
}

# Do we have a parallel port?
$ppt ++ if -e '/proc/parport/0/hardware';

print $mem if defined $mem;

# Look through the various hashes we have
# built, and print some hardware stats.
# (CPU's, TTY's, Floppys, etc.. Stuff we
# can have more than one of.

for my $key (keys %cpus) {
    print "$cpus{$key} $key $speed MHz processor";
    print $cpus{$key} > 1 ? "s\n" : "\n";
}
for my $key (keys %ttys) {
    print "$ttys{$key} $key serial port";
    print  $ttys{$key} > 1 ? "s\n" : "\n";
} 
for my $key (keys %fdc) {
    print "$fdc{$key} $key floppy controller";
    print $fdc{$key} > 1 ? "s\n" : "\n";
}
for my $key (keys %floppy) {
    print "$floppy{$key} $key floppy drive";
    print $floppy{$key} > 1 ? "s\n" : "\n";
}
for my $key (keys %graphics) {
    print "$graphics{$key} $key graphics device";
    print $graphics{$key} > 1 ? "s\n" : "\n";
}

# I guess the original author assumed a person
# could have only one of these.

if (defined($tmr)) {
    print "$tmr timer controller\n";
}
if (defined($kbd)) {
    print "$kbd keyboard";
    print $kbd > 1 ? "s\n" : "\n";
}
if (defined($ppt)) {
    print "$ppt parallel port";
    print $ppt > 1 ? "s\n" : "\n";
}

# Display what ethernet interfaces we have,
# I think IP aliasing will make this look
# misleading (not sure). May want to add
# dialup interfaces later.

if ((my $n = @eth) > 0) {
    print "$n ethernet interface";
    print $n > 1 ? "s:\n" : ":\n";
    for $eth (@eth) {
        print "`->  $eth\n";
    }
}

# Print IDE device statistics.
$ides ||= 0;
print "$ides IDE device";
print  $ides > 1 ? "s:\n" : ":\n";

print "`->  $hda" if defined $hda;
print "`->  $hdb" if defined $hdb;
print "`->  $hdc" if defined $hdc;
print "`->  $hdd" if defined $hdd;

if (defined($scsi)) {
    $scsi =~ s~.*detected ~~;
    $scsi =~ s~total\.~~;
    print $scsi;

    open(SCSI, '/proc/scsi/scsi') 
        || die "Can't read /proc/scsi/scsi: $!\n";
    
    DEVICE:
    while (my $line = <SCSI>) {
        next DEVICE unless $line =~ m~Vendor~;
        chomp($line);
        $line =~ s~.*Vendor:\s*~~;
        $line =~ s~\s*Rev:.*~~;
        $line =~ s~Model:\s*~~;
        print "`->  $line";
    }

    close(SCSI);
}

open(PCI, '/proc/pci') 
    || die "Can't read /proc/pci: $!\n";

print "PCI bus devices:\n";
while (my $line = <PCI>) {
    if ($line =~ /^\s*Bus/) {
        $line = <PCI>;
        $line =~ s~^\s+~~;
        print "`->  $line";
    }
}

close(PCI);
__END__

anm
-- 
Andrew N. McGuire
[EMAIL PROTECTED]
perl -le'print map?"(.*)"?&&($_=$1)&&s](\w+)]\u$1]g&&$_=>`perldoc -qj`'

==
HTH. Bob L.
-- 
Robert Lynch     Berkeley CA USA    [EMAIL PROTECTED]


------------------------------

From: Stuart <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.hardware,comp.os.linux.setup
Subject: CDR to Scsi
Date: Tue, 3 Apr 2001 16:36:07 -0400

hey I have the kernel 2.4.3 install on a redhat 7 system

AMD tbird 750
352 MB of RAM
500 MB of swap

I have scsi-ide as a module along with some other scsi and usb storage 
options.

I cant make my cdr drive /dev/hdd  be /dev/scd0

Please help!
Stuart


------------------------------

From: David Schwartz <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.networking
Subject: Re: TCP/IP socket buffering
Date: Tue, 03 Apr 2001 14:45:57 -0700



hebre wrote:

> Problem:
>     When client sends sequense of packets to server and server starts to
> receive them after some timeout (when all packets have been sent) it gets
> all packets in one recv() call, and buffer contains these in concatenated
> state. I have no information about this packets' format and can't to
> separate them, but I have to do it.

        If you have no information about where the boundaries are, how can you
separate them?

        DS

------------------------------

From: David Schwartz <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: HELP!!! Why does this crash the kernel
Date: Tue, 03 Apr 2001 14:48:06 -0700



Douglas Hendrix wrote:

> Does anyone know why this is so fatal to the linux kernel?

        You really shouldn't mess with the DMA controller from userspace.

        DS

------------------------------

From: David Schwartz <[EMAIL PROTECTED]>
Subject: Re: setsockopt() return "protcol not available" please help
Date: Tue, 03 Apr 2001 14:50:21 -0700



"FREDRIK LINDSTRÖM" wrote:

>      if(setsockopt((*s_sockInf)->sock, SOL_SOCKET, SO_RCVTIMEO, (char
> *)&rcvTime, sizeof(rcvTime))
>         || setsockopt((*s_sockInf)->sock, SOL_SOCKET, SO_SNDTIMEO, (char
> *)&sndTime, sizeof(sndTime))){

        Forget trying to do this. Just write your own send/recv functions that
implement the timeouts using alarm, select, or poll.

        DS

------------------------------

From: David Schwartz <[EMAIL PROTECTED]>
Subject: Re: Shared libs and memory usage
Date: Tue, 03 Apr 2001 14:53:42 -0700



Giuliano Pochini wrote:

> RSS-SHARE remains almost the same when libgd and libdbm are statically
> linked.
> 
> Bye.

        My guess is that the libraries aren't actually resident because most of
their code hasn't been used yet. It will fault in.

        DS

------------------------------

From: David Schwartz <[EMAIL PROTECTED]>
Subject: Re: /etc/init.d/function:daemon()
Date: Tue, 03 Apr 2001 14:58:26 -0700


Byron Young wrote:
 
> The RedHat script file /etc/init.d/functions contains function daemon(),
> which starts daemons. All the supplied start up scripts start services
> that have a command line option to place them in daemon mode. SMBD for
> example has the -D option. Some services that should be started as
> daemons have no command line option to place them in daemon mode. These
> services must use & (background) on the command line. What is the best
> way, when invoking daemon(), to start one of these programs?

daemon <whatever> &

        DS

------------------------------

From: David Schwartz <[EMAIL PROTECTED]>
Subject: Re: How to call a function and don't wait for return
Date: Tue, 03 Apr 2001 15:01:02 -0700


tlin wrote:
> 
> hi,
> 
> I want to initialize some functions when I load my module into the kernel.
> These functions need to share some common data within this module,
> and basically, they will never end until the module is terminated.
> 
> I don't know whether it is possible? If yes, then how to implement it?
> Thanks a lot!
> 
>       - tao

        I think what you're asking to do is create a 'process' (really a
thread) that runs at kernel level and is scheduled. Check out all the
other code that does this, keventd, kapm-idled, kswapd, kreclaimd,
bdflush, kupdated, and so on.

        DS

------------------------------

From: David Schwartz <[EMAIL PROTECTED]>
Subject: Re: cpu scheduling problem
Date: Tue, 03 Apr 2001 15:02:27 -0700



Simon J wrote

>                but there has a problem at time 4, when time reach 4, we know
> job1 will swap out and at the same time

        In a single CPU system, two things *never* happen at the same time.

        DS

------------------------------

From: Noe Nieto <[EMAIL PROTECTED]>
Subject: KERNEL PANIC on Mandrake 7.2
Date: Wed, 04 Apr 2001 00:30:10 -0000

Hello,
I recently downloaded mandrake 7.2...
The instalation process seemend to be succes.... but when i restarted my 
machine i got that screen before a radical hang up:
linux version 2.2.17-mdk
. 
. 
. 
. 
..
memory 127668K/131072k available
(113 k kernel code, 416k reserved, 1724k data, 128k init, 0k bigmem)
general protection fault:0000
cpu:0
eip:0010
. 
. 
process swaper (pid: 0, process nr:0 , stackpage=c024d000)
stack: c010600 ......
. 
. 
code: 89 07 0b 3f 83 ee 01 73 c4 c7 07 00 00 00 00 fa c7 45 08 2b
Kernel Panic: atempted to kill iddle task!
In swaper tasl- not sincing.

well
i hope ypu helpme....

--
Posted via CNET Help.com
http://www.help.com/

------------------------------

From: Rick Ace <[EMAIL PROTECTED]>
Subject: Re: did anyone have problems with Daylight Savings changeover?
Date: Tue, 03 Apr 2001 22:30:11 -0400

"Håkon Alstadheim" wrote:

> Set your hardware clock to UTC, and change the appropriate config
> things. If you don't want to do that, live with it, or boot windows
> once after every change (i.e. once in fall and once in spring) . It
> will adjust your hardware clock.

Hmmm.  Windows might be good for something after all  :oP

------------------------------

From: Gu Weining <[EMAIL PROTECTED]>
Subject: Re: How to read/write kernel addr, say c0101000?
Date: Tue, 03 Apr 2001 21:33:26 -0500


thank you, Josef and Ulrich. I solved my problem, following your
suggestion. I needn't subtract PAGE_OFFSET.

By the way, sounds like the following statements are useless.
Why?

if( get_user(address, (int *)arg) )  return -1;
...
if ( copy_to_user ((void *)arg, (void *)&tmp, sizeof(int)) ) return -1;

Weining Gu



------------------------------

From: [EMAIL PROTECTED] (David Efflandt)
Subject: Re: CDR to Scsi
Date: Wed, 4 Apr 2001 03:31:17 +0000 (UTC)
Reply-To: [EMAIL PROTECTED]

On Tue, 3 Apr 2001 16:36:07 -0400, Stuart <[EMAIL PROTECTED]> wrote:
>hey I have the kernel 2.4.3 install on a redhat 7 system
>
>AMD tbird 750
>352 MB of RAM
>500 MB of swap
>
>I have scsi-ide as a module along with some other scsi and usb storage 
>options.
>
>I cant make my cdr drive /dev/hdd  be /dev/scd0

The easiest way is to make sure that ATAPI CDROM support is NOT compiled
into the kernel (it can be a module if you have alternate kernels).  
Compile SCSI emulation, SCSI support and SCSI generic support (for sg
devices) into the kernel.  Then your CDR should be recognized by scsi. 
SCSI CDROM support can be a module (sr_mod).

Then you should be able to mount the scd# as cdrom or record to the sg#
(or bus,id,lun listed by cdrecord -scanbus).

There are other ways to just manupulate the modules instead, but that
varies with the kernel version (2.2.x vs. 2.4.x) and will NOT work if
ATAPI CDROM support is built into your kernel.

-- 
David Efflandt  [EMAIL PROTECTED]  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/

------------------------------


** FOR YOUR REFERENCE **

The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:

    Internet: [EMAIL PROTECTED]

You can send mail to the entire list by posting to the
comp.os.linux.development.system newsgroup.

Linux may be obtained via one of these FTP sites:
    ftp.funet.fi                                pub/Linux
    tsx-11.mit.edu                              pub/linux
    sunsite.unc.edu                             pub/Linux

End of Linux-Development-System Digest
******************************

Reply via email to