Linux-Development-Sys Digest #825, Volume #7      Fri, 5 May 00 13:13:17 EDT

Contents:
  Re: Have new parallel port - but it's PCI!! (J Bland)
  Info on functions ("Andrew Rodgers")
  SOCK_RAW and low level Ethernet Frames. (mark)
  Re: Device driver trouble (Zoran Cutura)
  Re: MMAP with /dev/zero usage ??? ([EMAIL PROTECTED])
  Re: what is "BSS"? (Lew Pitcher)
  dev_get("eth0:0") (Emmanuel Chaput)
  Waiting on two threads (Brian Lalor)
  Re: gdb on /proc/kcore help? SOLVED! (Eric Taylor)
  Re: Info on functions (Josef Moellers)
  Re: what is "BSS"? (bill davidsen)
  Re: device driver devel HELP ("Timur Tabi")
  Re: MMAP with /dev/zero usage ??? (Olivier Spielmann)
  Re: Waiting on two threads ([EMAIL PROTECTED])
  Re: MMAP with /dev/zero usage ??? ([EMAIL PROTECTED])
  Access user buffer from different context (liran)
  Re: what is "BSS"? (Lew Pitcher)
  Real Time Programming in Linux (Simon Wakley)

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

From: [EMAIL PROTECTED] (J Bland)
Crossposted-To: comp.os.linux.hardware
Subject: Re: Have new parallel port - but it's PCI!!
Date: 5 May 2000 09:27:12 GMT

On Wed, 03 May 2000 04:43:51 GMT, Mark Graybill <[EMAIL PROTECTED]> wrote:
>
>Chris Rankin wrote in message <8egr8v$689$[EMAIL PROTECTED]>...
>>/proc/parport/1/hardware:
>>base:   0x278
>>irq:    9
>
>
>Did you try a different IRQ? (e.g. 5)
>

I have two parallel ports on my server, one being a PCI card. Adding the
following hardware parameter to lilo does the trick if the parport support
is compiled into the kernel (there's a similar thing that works in
modules.conf, have a look, it may be listed in there already):

parport=0x3bc,7 parport=0x9800,auto

These numbers were found by pretty much trying any of the standard parport
ones and the I/O info found from /proc/pci for the parallel port card.

It all works swimmingly.

Professor John Frink

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

From: "Andrew Rodgers" <[EMAIL PROTECTED]>
Subject: Info on functions
Date: Fri, 05 May 2000 10:36:07 GMT

I'm using the suse distribution.  How do I find out about certain functions
such as iopl and outb?
I used the man pages, but they give limited info.

Thanks




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

From: mark <[EMAIL PROTECTED]>
Subject: SOCK_RAW and low level Ethernet Frames.
Date: Fri, 05 May 2000 12:23:35 +0100

Hi,
    I'm currently working on a program which creates an Ethernet Frame
from scratch and transmits (sendto())  it out onto the LAN. I've got a
couple of problems with it.

1) When it gets up to around 1500 Frames Per Second (146 Bytes per frame

on 10Mbps LAN i.e around 10% utilisation) the are a load of collisions,
and I'm not sure what causing them. The sendto() doesn't report any
errors. I know (At slow speeds) the frames are correctly formed as I've
checked them with a LAN analyser.

2) This is possibly related to (1) as it's something which I thought I
might be causing the problem. Currently in the socket() function I'm
using SOCK_PACKET. Which according to the man pages is obsolete and
should be replaced with SOCK_RAW. However it's not a direct replacement.

I've looked though the man pages and on the net, but haven't found out
what changes I have to make to get SOCK_RAW to work (I assume it's what
I need). Does anyone know what these differences are, or where I can
find out.

>From what I can see I need to use the sock_addr_ll (Think I've got the
name wrong, can't see it at the moment) structure. But I'm not sure how
this ties inwith the old structure. I also want to specifiy what
ethernet to use i.e. eth2.

Many thanks for any help

Mark




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

From: Zoran Cutura <[EMAIL PROTECTED]>
Subject: Re: Device driver trouble
Date: Fri, 05 May 2000 14:08:51 +0200

Development System Linux OS wrote:
> 
> Let me re-type my questions here again!
> I am testing the same module from A. RUBINI book:
> /* hello.c */
> #define MODULE
> #include <linux/module.h>
> int init_module(void) {printk("<1>Hello World\n"); return 0;}
> void cleanup_module(void) {printk("<1>Goodbye World\n");}
> 
> % gcc -o hello.o hello.c   --after compile I got the following errors
> /usr/lib/crt1.o(.text+0x18): undefined reference to `main'
> /tmp/ccij2Fle.o: In function `init_module':
> /tmp/ccij2Fle.o(.text+0x9): undefined reference to `printk'
> /tmp/ccij2Fle.o: In function `cleanup_module':
> /tmp/ccij2Fle.o(.text+0x21): undefined reference to `printk'
> collect2: ld returned 1 exit status
> 
> Can anyone help me to get around with this problem, thanks
> 
> Wade
> 
> * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
> The fastest and easiest way to search and participate in Usenet - Free!

Read the docs for gcc!

>From the gcc man page
 -c     Compile or assemble the source files,  but  do  not
        link.  The compiler output is an object file corre�
        sponding to each source file.

        

        Z

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

From: [EMAIL PROTECTED]
Subject: Re: MMAP with /dev/zero usage ???
Date: Fri, 5 May 2000 12:10:17 +0100

Tim Roberts <[EMAIL PROTECTED]> wrote:
: Olivier Spielmann <[EMAIL PROTECTED]> wrote:
:>
:>I am running RH 5.2 and would like to allocate more than 4096bytes of
:>memory at a time. Then I tried mmap with the /dev/zero device.

You don't need to use mmap to allocate more than 4K of
memory. malloc will work quite happily up to around 2GB
(and more on 64 bit machines).

: I've seen this trick used elsewhere.  Can you (patiently) help me
: understand why this is preferable to, for example, malloc?

Malloc will use one of two mechanisms underneath - one
being brk/sbrk (old skool Unix :-) and the other being
mmap /dev/zero. So using mmap /dev/zero is just a more
low-level & primitive way of allocating pages of memory
to your process. It might be useful in certain very limited
cases (eg. you want to write a replacement to malloc or
you want to implement garbage collection or the like), but
it's almost always better to use malloc in normal C code.

Rich.

-- 
[EMAIL PROTECTED] | Free email for life at: http://www.postmaster.co.uk/
BiblioTech Ltd, Unit 2 Piper Centre, 50 Carnwath Road, London, SW6 3EG.
+44 171 384 6917 | Click here to play XRacer: http://xracer.annexia.org/
--- Original message content Copyright � 2000 Richard Jones ---

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

From: [EMAIL PROTECTED] (Lew Pitcher)
Subject: Re: what is "BSS"?
Reply-To: [EMAIL PROTECTED]
Date: Fri, 05 May 2000 12:47:19 GMT

On Fri, 05 May 2000 08:58:58 +0200, Josef Moellers
<[EMAIL PROTECTED]> wrote:

>JKFang wrote:
>> =
>
>> What does it mean by "Cleaning BSS" ?
>> This question comes when reading some document about linux kernal.
>
>AFAIK "BSS" is an acronym for "block starting segment",
>whateverthatmeans.

In the ancient assembly language that Unix was first developed on, the
BSS pseudo-instruction was used to reserve space without initializing
it. Something like a DS (Define Space) pseudo-instruction on more
current assemblers.

Since BSS segments were assembled to the high end of the DATA segment
(IIRC), they effectively began at the base of the heap. 



Lew Pitcher
System Consultant
Toronto Dominion Financial Group

([EMAIL PROTECTED])


(Opinions expressed are my own, not my employer's.)

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

From: Emmanuel Chaput <[EMAIL PROTECTED]>
Subject: dev_get("eth0:0")
Date: Fri, 05 May 2000 12:55:22 +0000

   In a network driver code, I use "dev_get(another_device)"
It works fine (eg with another_device="eth0") but it fails
with another_device="eth0:0" ! Of course eth0:0 has been
ifconfig'd UP and works fine ...

   Who could give me some help on this point ?

-- 
Emmanuel Chaput       D�pt T�l�com & R�seau, ENSEEIHT
*5 61 58 82 10            [EMAIL PROTECTED]

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

From: Brian Lalor <[EMAIL PROTECTED]>
Subject: Waiting on two threads
Date: 05 May 2000 08:46:04 -0400


I'm trying to write a program that spawns two threads and then waits for them
to finish.  The problem is that I don't know ahead of time which thread will
finish first.  As I understand the signaling methodology
(pthread_cond_signal()), I can only wait on one signal at a time, and spin
locking just sucks up CPU.  Here's a basic layout of what I'm trying to do:

typedef struct _mystruct_t {
  pthread_mutex_t mutex;
  pthread_cond_t cond;
} mystruct_t;

void send_file(void *ptr) 
{
  mystruct_t *a_struct;
  a_struct = (mystruct_t *)ptr;

  /* send data to server here */

  pthread_cond_signal(&(a_struct->cond));
}

main () 
{
  mystruct_t struct1, struct2;

  /* init mutexes and conds in structs */

  pthread_create(&writer1, NULL, (void *)&send_file, (void *)&struct1);
  pthread_create(&writer2, NULL, (void *)&send_file, (void *)&struct2);

  /**
     Now what?
   **/
}


Its looking like I should wait on one of the conditional variables, test to
see if the other's done (have a done_sending var in the struct), and wait on
the second conditional if it is not; however, I'd really like to be notified
when *either* thread is done first (arbitrarily), rather than taking the
chance that I'll be waiting on the thread that's finished second.

Anyone have any ideas?

Thanks,
B

--
Brian Lalor, Web Honkey
netDrives, Inc.
[EMAIL PROTECTED]
607-272-5650 x7167

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

From: Eric Taylor <[EMAIL PROTECTED]>
Subject: Re: gdb on /proc/kcore help? SOLVED!
Date: Fri, 05 May 2000 07:34:02 -0700

Eric Taylor wrote:
> 
> Josef Moellers wrote:
> >
> > Eric Taylor wrote:
> > >
> > > hi:
> > > I'm reading Rubini' driver book and trying to
> > > look at some variables i've added to my kernel.
> > >
> > > In gdb, the symbol addresses are off from when i check
> > > /proc/ksyms. Off about 200 bytes or so. My new globals
> > > don't show up in ksyms.



Problem solved!

It was my misunderstanding of how the system boots up.

When installing, i didn't put lilo on my hard disk, but
rather booted up from a lilo floppy. I did this because
I was afraid to mess with my hard-drive's boot sectors
as I boot other o.s. This I now see was a big mistake.

Because of that, normal docs about runing new kernels
don't apply, and so my problem was i was not running my
modified kernel. Once I found out how to create a boot
floppy with my new kernel it all worked fine.

--e

Oh, I did need to add my symbol in 2 places to get /proc/ksyms
to show it.

In sched.c i added an external variable.

int myvar;

so, in sched.h i had to add an 

extern int myvar;

Then in ksyms i added the EXPORT_SYMBOL(myvar) as suggested.

thanks

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

From: Josef Moellers <[EMAIL PROTECTED]>
Subject: Re: Info on functions
Date: Fri, 05 May 2000 16:48:10 +0200

Andrew Rodgers wrote:
> =

> I'm using the suse distribution.  How do I find out about certain funct=
ions
> such as iopl and outb?
> I used the man pages, but they give limited info.

UTSL! They are kernel functions. Unfortunately no man pages exist for
these. You need to reference the kernel source code.

-- =

Josef M=F6llers
Fujitsu Siemens Computers
SHV Server DS 1

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

From: [EMAIL PROTECTED] (bill davidsen)
Subject: Re: what is "BSS"?
Date: 5 May 2000 15:22:28 GMT


In article <[EMAIL PROTECTED]>,
Lew Pitcher <[EMAIL PROTECTED]> wrote:

| In the ancient assembly language that Unix was first developed on, the
| BSS pseudo-instruction was used to reserve space without initializing
| it. Something like a DS (Define Space) pseudo-instruction on more
| current assemblers.
| 
| Since BSS segments were assembled to the high end of the DATA segment
| (IIRC), they effectively began at the base of the heap. 

  Since I was actually writing assembler at that time, let me clarify...

BSS - block starting with symbol. The address of the symbol is the
address of the first byte (or word in those days) of the buffer.

BFS - block followed by symbol. The value of the symbol is the first
address after the end of the buffer.

  This was used for the hardware stack stuff, which either (a) stored
data into a buffer through a pointer in memory then incremented the
address and decremented the space remaining field, for which you use
BSS, or (b) decrement the address in the pointer, store data in the new
address, and increment the count of space used. Note that one uses the
address before changing it, the other changes it then uses it. This is
what you need.

  While using memory pointers for stacks instead of a dedicated SP
register added memory use and was slower, being able to have many
stacks, sized in BCD or ASCII character size, or word, or double word,
or size of all registers, or any arbitrary size, made recursive
programming much easier. It also made compiler writing fun!

  There were 64 possible addressing mode (tag fields), including
register indirect, register indirect and indirect again, memory indirect
and add register... man, those were the days when a devious programmer
could write well commented write-only code ;-)

  I wrote ove a 100k lines of code using this stuff, I'm amazed that it
still sticks. MULTICS, the father of UNIX, was developed on the GE 645,
one of the first virtual memory machines in production. Of course then
GE sold the computer division to put capital into the atomic energy
sector which was obviously going to grow faster...

-- 
bill davidsen <[EMAIL PROTECTED]>  CTO, TMR Associates, Inc
  "Doing interesting things with little computers since 1979"(tm)
The hardest test of maturity is knowing the difference between
resisting temptation and missing a once-in-a-lifetime opportunity.

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

From: "Timur Tabi" <[EMAIL PROTECTED]>
Subject: Re: device driver devel HELP
Date: Fri, 5 May 2000 10:33:21 -0500

<[EMAIL PROTECTED]> wrote in message news:8etmmk$sks$[EMAIL PROTECTED]...
> hi guys ,
>          i am trying to write a new device driver for my mouse.
> should i know the kernel internals completely or onle
> alessandro rubini is enough. thank you
>  gowtham

I think your biggest problem is that Rubini's book is for the 2.0 kernel
only.  It talks about some of the changes in the 2.1 kernel, but they're not
all correct.  And chances are, 2.4 will be available about the same time
your driver is finished.

Rubini's book is very good, but you'll need to cross-reference anything you
learn with the kernel and other device drivers.  But you certainly won't
need to know the COMPELTE kernel internals.  Just be prepared to examine the
source code.




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

Date: Fri, 05 May 2000 08:30:15 -0700
From: Olivier Spielmann <[EMAIL PROTECTED]>
Subject: Re: MMAP with /dev/zero usage ???

Thank you for your help first.

I have a new problem. I have 128 MB of RAM and 128 swap mem space under RH 5.2.
With mmap, I am able to allocate 2 times 200 MB. How come this is possible,
because I do not have enough resource ? Is mmap reserving memory as with malloc
? If not is there a way to make this memory private (nobody can write or read it
except the actual process) ?

Thanks

John Reiser wrote:

> >   if ((area = (caddr_t)mmap(NULL,1024,PROT_READ|PROT_WRITE,0,fd,0)) ==
>
> The "flags" (fourth) argument to mmap should be MAP_PRIVATE | MAP_ANONYMOUS;
> and the file descriptor "fd" is not needed in this case (use "0" instead)
> to get a page of zeroes.

--
===========================================================================================

Olivier Spielmann
Communication Systems EPFL student (Switzerland)
Intern (thesis internship)

3Com Corporation
5400 Bayfront Plaza
M/S: 3219
Santa Clara, CA 95052-8145

Work: ++1 (408) 326 6304
Fax:  ++1 (408) 326 8188



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

From: [EMAIL PROTECTED]
Subject: Re: Waiting on two threads
Date: Fri, 5 May 2000 16:15:13 +0100

Brian Lalor <[EMAIL PROTECTED]> wrote:

: I'm trying to write a program that spawns two threads and then waits for them
: to finish.  The problem is that I don't know ahead of time which thread will
: finish first.  As I understand the signaling methodology
: (pthread_cond_signal()), I can only wait on one signal at a time, and spin
: locking just sucks up CPU.  Here's a basic layout of what I'm trying to do:

I had a similar problem. Basically I solved it by
creating the threads `joinable' (the default) and
waiting for them to finish one at a time using
pthread_join(3). It doesn't matter which order you
wait for them.

Rich.

-- 
[EMAIL PROTECTED] | Free email for life at: http://www.postmaster.co.uk/
BiblioTech Ltd, Unit 2 Piper Centre, 50 Carnwath Road, London, SW6 3EG.
+44 171 384 6917 | Click here to play XRacer: http://xracer.annexia.org/
--- Original message content Copyright � 2000 Richard Jones ---

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

From: [EMAIL PROTECTED]
Subject: Re: MMAP with /dev/zero usage ???
Date: Fri, 5 May 2000 17:08:41 +0100

Olivier Spielmann <[EMAIL PROTECTED]> wrote:
: Thank you for your help first.

: I have a new problem. I have 128 MB of RAM and 128 swap mem space under RH 5.2.
: With mmap, I am able to allocate 2 times 200 MB. How come this is possible,
: because I do not have enough resource ? Is mmap reserving memory as with malloc
: ? If not is there a way to make this memory private (nobody can write or read it
: except the actual process) ?

If you have a 2.2 kernel, then try:

echo 0 > /proc/sys/vm/overcommit_memory

and see if you can still do that.

Linux only allocates memory when you write to it (although I
believe the default behaviour changed in 2.2).

Rich.

-- 
[EMAIL PROTECTED] | Free email for life at: http://www.postmaster.co.uk/
BiblioTech Ltd, Unit 2 Piper Centre, 50 Carnwath Road, London, SW6 3EG.
+44 171 384 6917 | Click here to play XRacer: http://xracer.annexia.org/
--- Original message content Copyright � 2000 Richard Jones ---

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

From: liran <[EMAIL PROTECTED]>
Subject: Access user buffer from different context
Date: Fri, 05 May 2000 09:00:58 -0700

Hi,
I want to know is it possible to access user space buffer
from other context inside the kernel without doing context
switch.
is it possible to make user space address visible all
other kernel space without considire which context I am.
if I understood correct copy_to_user will work only if you
are in the right context.
If somebody knows the answer or can reference me to a
sample code it will be very helpfull.

Thanks Liran.


* Sent from AltaVista http://www.altavista.com Where you can also find related Web 
Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful

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

From: [EMAIL PROTECTED] (Lew Pitcher)
Subject: Re: what is "BSS"?
Reply-To: [EMAIL PROTECTED]
Date: Fri, 05 May 2000 16:25:57 GMT

Bill,

Thank you for that interesting bit of history. I'm always amazed at
how much of current practice and technology is just a reinvention (or
restatement) of prior art. 

And I'm glad to (indirectly) talk with someone who worked on the
much-legendary MULTICS o/s. Again, in this field, the more things
change, the more they remain the same.

Take care...


Lew Pitcher

Master Codewright and JOAT-in-training



On 5 May 2000 15:22:28 GMT, [EMAIL PROTECTED] (bill davidsen) wrote:

>
>In article <[EMAIL PROTECTED]>,
>Lew Pitcher <[EMAIL PROTECTED]> wrote:
>
>| In the ancient assembly language that Unix was first developed on, the
>| BSS pseudo-instruction was used to reserve space without initializing
>| it. Something like a DS (Define Space) pseudo-instruction on more
>| current assemblers.
>| 
>| Since BSS segments were assembled to the high end of the DATA segment
>| (IIRC), they effectively began at the base of the heap. 
>
>  Since I was actually writing assembler at that time, let me clarify...
>
>BSS - block starting with symbol. The address of the symbol is the
>address of the first byte (or word in those days) of the buffer.
>
>BFS - block followed by symbol. The value of the symbol is the first
>address after the end of the buffer.
>
>  This was used for the hardware stack stuff, which either (a) stored
>data into a buffer through a pointer in memory then incremented the
>address and decremented the space remaining field, for which you use
>BSS, or (b) decrement the address in the pointer, store data in the new
>address, and increment the count of space used. Note that one uses the
>address before changing it, the other changes it then uses it. This is
>what you need.
>
>  While using memory pointers for stacks instead of a dedicated SP
>register added memory use and was slower, being able to have many
>stacks, sized in BCD or ASCII character size, or word, or double word,
>or size of all registers, or any arbitrary size, made recursive
>programming much easier. It also made compiler writing fun!
>
>  There were 64 possible addressing mode (tag fields), including
>register indirect, register indirect and indirect again, memory indirect
>and add register... man, those were the days when a devious programmer
>could write well commented write-only code ;-)
>
>  I wrote ove a 100k lines of code using this stuff, I'm amazed that it
>still sticks. MULTICS, the father of UNIX, was developed on the GE 645,
>one of the first virtual memory machines in production. Of course then
>GE sold the computer division to put capital into the atomic energy
>sector which was obviously going to grow faster...
>
>-- 
>bill davidsen <[EMAIL PROTECTED]>  CTO, TMR Associates, Inc
>  "Doing interesting things with little computers since 1979"(tm)
>The hardest test of maturity is knowing the difference between
>resisting temptation and missing a once-in-a-lifetime opportunity.


Lew Pitcher
System Consultant
Toronto Dominion Financial Group

([EMAIL PROTECTED])


(Opinions expressed are my own, not my employer's.)

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

From: Simon Wakley <[EMAIL PROTECTED]>
Subject: Real Time Programming in Linux
Date: Fri, 05 May 2000 17:01:18 GMT


I am porting a robotic controller system to linux, and my program has to
spew out data over the parallel port every 20ms.  It does not have to be
exactly every 20ms, but it must average exactly that.  I have tried
starting a high priority thread from my XWindows app, but it does not
run at very high priority and gets blocked when I do some windows
intensive activity.

Does anyone know about programming in real time for linux or how you go
about that.??  I had been handling this with a separate processor, but
would like to integrate it all into Linux for speed of operation.

(BTW the parallel port device driver that talks to the H/W is in C.
would it be a lot faster in assembler if that can be done???)

Thanks

Simon

-- 
Simon Wakley

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


** 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 (and comp.os.linux.development.system) via:

    Internet: [EMAIL PROTECTED]

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