Linux-Development-Sys Digest #704, Volume #8      Tue, 8 May 01 23:13:17 EDT

Contents:
  Re: getting 'ioctl failed: Inappropriate ioctl for device'
  Re: getting 'ioctl failed: Inappropriate ioctl for device' (k)
  Re: getting - failed ioctl (k)
  why a separate process for each thread on Linux ("Alex Ho")
  Re: why a separate process for each thread on Linux (Alexander Viro)
  Re: getting 'ioctl failed: Inappropriate ioctl for device'
  metadata and normal data (Zhiyong Xu)
  Re: wait() and lost children ([EMAIL PROTECTED])
  Re: why a separate process for each thread on Linux (Juergen Heinzl)
  Re: What does the _REENTRANT symbol enable ? (Juergen Heinzl)
  looking for user space program example... (k)
  Re: looking for user space program example...
  Re: looking for user space program example... (k)
  Re: cache coherency, threads, SMP ("D. Stimits")
  Re: looking for user space program example...
  How to unblocking a thread blocked on an accept() ( try 2 ) ("Rosimildo daSilva")
  Re: STLport 4.0 & g++ 2.96 (Steve Connet)

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

From: [EMAIL PROTECTED] ()
Subject: Re: getting 'ioctl failed: Inappropriate ioctl for device'
Date: Tue, 08 May 2001 17:26:44 -0000

In article <dEVJ6.6349$[EMAIL PROTECTED]>,
 <[EMAIL PROTECTED]> wrote:

>I have /sbin/insmod my driver and it is successful. I also executed 'mknod' so
>that my device is in /dev directory. Now, from the user space, I opened this
>device and it is successful. But when I try to send an ioctl, I get 'ioctl
>failed: Inappropriate ioctl for device' message. Also, I see none of the other
>calls like open in my fops are getting called either. I know this because, I
>have printks in my fops--open call and I don't see it in the /var/log/messages.
>I thought that this should be called when I do - an open on this device from the
>User Space. Is my assumption wrong. Any thoughts ...

It sounds like you aren't really opening the driver you thought you
were opening.  Are you sure the node in /dev has the right numbers?
Did you register the device and did you check for an error return from
the registration call?  Without seeing your source all anyone can do is
guess at things that could have gone wrong.

--
http://www.spinics.net/linux

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

From: k <[EMAIL PROTECTED]>
Subject: Re: getting 'ioctl failed: Inappropriate ioctl for device'
Date: Tue, 08 May 2001 18:12:10 GMT

-->more /proc/devices
Character devices:
1 mem
2 pty
3 ttyp
4 ttyS
5 cua
7 vcs
10 misc
14 sound
128 ptm
136 pts
162 raw
180 usb
254 plx

Block devices:
2 fd
3 ide0
22 ide1


-->ls -l /dev/plx
crw-r--r--    1 root     root     254,   0 May  7 20:23 /dev/plx

I did a cut & paste from my terminal. So, my device is sitting there--/dev/plx.
It's major number is 254. I am using this user space code to send a test ioctl.

#include<stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>


main()
{ 
int fh=0;

if((fh = open("/dev/plx", O_CREAT)) <= 0)
printf("failed to open device\n");
else{
if (ioctl(fh, 0x20) != 0)
perror("ioctl failed");
close(fh);
}
}

When I run this code, I get the failed ioctl message. Also, like I said before,
why am I not seeing the printk message in my open function from my fops array.
When I do the open on my device above, I get a valid file pointer. So, when it
opens the device, should not it call the associated open function. Here is my
fops array:

static struct file_operations plx_fops =
{
NULL,           /* lseek */
NULL,           /*plx_read,*/
NULL,           /*plx_write,*/
NULL,           /* readdir */
NULL,           /* poll */
plx_ioctl,
NULL,           /*plx_mmap,*/
plx_open,       /*plx_open,*/
NULL,           /* flush */
NULL,           /*plx_release,*/
NULL,           /* fsync */
NULL,           /* fasync */
NULL,           /* check_media_change */
NULL,           /* revalidate */
NULL            /* lock */
};

This is just an experimental array//so I left most of them NULLs. But why are
they not getting called......


In article <[EMAIL PROTECTED]>,  says...
>
>In article <dEVJ6.6349$[EMAIL PROTECTED]>,
> <[EMAIL PROTECTED]> wrote:
>
>>I have /sbin/insmod my driver and it is successful. I also executed 'mknod' so
>>that my device is in /dev directory. Now, from the user space, I opened this
>>device and it is successful. But when I try to send an ioctl, I get 'ioctl
>>failed: Inappropriate ioctl for device' message. Also, I see none of the other
>>calls like open in my fops are getting called either. I know this because, I
>>have printks in my fops--open call and I don't see it in the /var/log/messages.
>>I thought that this should be called when I do - an open on this device from the
>>User Space. Is my assumption wrong. Any thoughts ...
>
>It sounds like you aren't really opening the driver you thought you
>were opening.  Are you sure the node in /dev has the right numbers?
>Did you register the device and did you check for an error return from
>the registration call?  Without seeing your source all anyone can do is
>guess at things that could have gone wrong.
>
>--
>http://www.spinics.net/linux



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

From: k <[EMAIL PROTECTED]>
Subject: Re: getting - failed ioctl
Date: Tue, 08 May 2001 18:21:17 GMT

here is my init code...

int init_module(void)
{
printk("init_module called\n");
plx_init();
return 0;
}

int plx_init()
{

Dev_major = register_chrdev (0, "plx", &plx_fops);
printk("Dev_major: %d\n",Dev_major);
return 0;
}

static struct file_operations plx_fops =
{
NULL,           /* lseek */
NULL,           /*plx_read,*/
NULL,           /*plx_write,*/
NULL,           /* readdir */
NULL,           /* poll */
plx_ioctl,
NULL,           /*plx_mmap,*/
plx_open,       /*plx_open,*/
NULL,           /* flush */
NULL,           /*plx_release,*/
NULL,           /* fsync */
NULL,           /* fasync */
NULL,           /* check_media_change */
NULL,           /* revalidate */
NULL            /* lock */
};

Hopefully, this sheds more light on what I am working with.

thanx,
k


In article <[EMAIL PROTECTED]>, Kasp
er Dupont says...
>
>[EMAIL PROTECTED] wrote:
>> 
>> I am getting this message: 'ioctl failed: Inappropriate ioctl for device'
>> Also, none of my fops are getting called including 'open'...when I look at my
>> kernel driver log in /var/log/messages...what am I doing wrong here ..any info
>> 
>> thanx,
>> k
>
>You have to describe your problem in more detail
>if anybody should be able to help you. Do you
>actually reference the f_ops structure in the
>right place? Why not post some of your code?
>
>-- 
>Kasper Dupont



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

From: "Alex Ho" <[EMAIL PROTECTED]>
Subject: why a separate process for each thread on Linux
Date: 08 May 2001 18:28:51 GMT

Does anyone know why both LinuxThread and PThreads on Linux are forking a
process for each thread?  Is there a thread lib for Linux that doesn't do
that.

I just want all secondary threads belonging to an application to run in the
same process as the main thread.


Best Regards,
Alex Ho





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

From: [EMAIL PROTECTED] (Alexander Viro)
Subject: Re: why a separate process for each thread on Linux
Date: 8 May 2001 15:04:45 -0400

In article <9d9dt3$[EMAIL PROTECTED]>,
Alex Ho <[EMAIL PROTECTED]> wrote:
>Does anyone know why both LinuxThread and PThreads on Linux are forking a
>process for each thread?

Why not? You can have VM shared between them, ditto for file descriptors,
etc. What else matters?

-- 
"You're one of those condescending Unix computer users!"
"Here's a nickel, kid.  Get yourself a better computer" - Dilbert.

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

From: [EMAIL PROTECTED] ()
Subject: Re: getting 'ioctl failed: Inappropriate ioctl for device'
Date: Tue, 08 May 2001 19:21:49 -0000

In article <_FWJ6.6511$[EMAIL PROTECTED]>,
k  <[EMAIL PROTECTED]> wrote:

>if((fh = open("/dev/plx", O_CREAT)) <= 0)

Why are you using O_CREAT?

--
http://www.spinics.net/linux

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

From: Zhiyong Xu <[EMAIL PROTECTED]>
Subject: metadata and normal data
Date: Tue, 08 May 2001 15:33:11 -0400

    How can I know the data stored in one buffer head is meta data or
just the ordinary data, is there any flags  in buffer head?
    And last time I heard in kernel 2.4.x, the disk I/Os are go through
two paths, one is page cache, and the other is buffer cache, and normal
data go through page cache, but meta data go through buffer cache, is it
true?

         Thanks.





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

From: [EMAIL PROTECTED]
Subject: Re: wait() and lost children
Date: 8 May 2001 19:49:08 GMT

On 08 May 2001 10:35:58 -0500 Greg Copeland <[EMAIL PROTECTED]> wrote:

| [EMAIL PROTECTED] writes:
|
|> On Tue, 08 May 2001 11:59:11 +0000 Kasper Dupont <[EMAIL PROTECTED]> wrote:
|> | [EMAIL PROTECTED] wrote:
|> |> 
|> |> I'm debugging a server program I did not write which has a loop
|> |> which involves doing a wait(NULL) call if it has reached its
|> |> maximum number of children.  What seems to be happening is that
|> |> if 2 or more children have exit status at the same time, the
|> |> number of wakeups is less than the number of such children, and
|> |> may even be as few as 1.  This is on Linux 2.4.  Is wait() allowed
|> |> to behave this way?  
|
| I personally like to keep a list of pids and use waitpid() if possible and
| signal the intent to exit to the parent.  Are you sure that all of your
| children are really exiting and not hanging in a race condition or skipped
| past your _exit() in an unexpected turn of logic?  In other words, are you
| sure that each and every child is really in a state whereby wait() will 
| really be doing what you expect it to be doing?

With this particular program, I'm not sure.  I do know the processes
do go away.  There is nothing hanging.  I can stop the master process
and watch them (or force them to) enter <defunct>, and when I continue
the master process, they all vanish.  At that time the master process
starts back just one child.  Added code to output the events in the
code only reports one instance of wait() returning.

-- 
=================================================================
| Phil Howard - KA9WGN |   Dallas   | http://linuxhomepage.com/ |
| [EMAIL PROTECTED] | Texas, USA | http://phil.ipal.org/     |
=================================================================

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

From: [EMAIL PROTECTED] (Juergen Heinzl)
Subject: Re: why a separate process for each thread on Linux
Date: Tue, 08 May 2001 20:40:35 GMT

In article <9d9g0d$[EMAIL PROTECTED]>, Alexander Viro wrote:
>In article <9d9dt3$[EMAIL PROTECTED]>,
>Alex Ho <[EMAIL PROTECTED]> wrote:
>>Does anyone know why both LinuxThread and PThreads on Linux are forking a
>>process for each thread?
>
>Why not? You can have VM shared between them, ditto for file descriptors,
>etc. What else matters?
[-]
It's a complete mess compared to other systems to start with.

See man 2 clone for more since threads are based on this system
call. Still things are free to change and beware as there's quite
a difference between fork(2) and clone(2). 

It's true though that, up to now, each thread gets its own process
id, but this doesn't make it a separate process.

Ta',
Juergen

-- 
\ Real name     : Juergen Heinzl                \       no flames      /
 \ EMail Private : [EMAIL PROTECTED] \ send money instead /

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

From: [EMAIL PROTECTED] (Juergen Heinzl)
Subject: Re: What does the _REENTRANT symbol enable ?
Date: Tue, 08 May 2001 20:52:54 GMT

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote:
>
>I was reading in John Goerzen's "Linux Programming Bible" that shared,
>dynamic libraries should be built with the _REENTRANT symbols defined
>for all source files that are compiled into it.
>
>What exactly does the _REENTRANT symbol enable in the system (ie libc)
>headers and elsewhere ?
[-]
I'm only aware of errno and h_errno becoming functions behind your
back since their values must be thread specific. Mind even a single
threaded application has one thread at least. It'd help at least to
make libraries useable with both, MT and non MT apps.

Still one is free to use functions like fputs_unlocked() for speed
reasons, but sure, in such cases the programmer had better aware what
he or she is doing, or might use other functions like gethostbyname()
which are not thread safe and so "import" non-threadsafe functions
behine ones back. In short, I'm not sure about how useful it really is.

I don't know the book mentioned btw, so take all this with a grain
of salt.

Ta',
Juergen

-- 
\ Real name     : Juergen Heinzl                \       no flames      /
 \ EMail Private : [EMAIL PROTECTED] \ send money instead /

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

From: k <[EMAIL PROTECTED]>
Subject: looking for user space program example...
Date: Tue, 08 May 2001 21:22:23 GMT

I am looking for a sample User space program which I can adapt for my ioctl test
code...I have a char driver registered in /dev and I can see it when I do 
more /proc/devices. Now, I am trying to comeup with some code that runs in the
User Space and does two things..
->Open my device
-> send ioctls to it.
My sample code which runs like
open("/dev/plx",O_RDWR,0666) is failing to return me a pointer to my device...






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

From: [EMAIL PROTECTED] ()
Subject: Re: looking for user space program example...
Date: Tue, 08 May 2001 21:40:44 -0000

In article <jsZJ6.6773$[EMAIL PROTECTED]>,
k  <[EMAIL PROTECTED]> wrote:
>I am looking for a sample User space program which I can adapt for my ioctl test
>code...I have a char driver registered in /dev and I can see it when I do 
>more /proc/devices. Now, I am trying to comeup with some code that runs in the
>User Space and does two things..
>->Open my device
>-> send ioctls to it.
>My sample code which runs like
>open("/dev/plx",O_RDWR,0666) is failing to return me a pointer to my device...

I assume by "failing to return me a pointer to my device" you mean
it is returning an error?  If so, what's errno after the open call?

Why do you have the 0666 argument? 

--
http://www.spinics.net/linux

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

From: k <[EMAIL PROTECTED]>
Subject: Re: looking for user space program example...
Date: Tue, 08 May 2001 22:02:42 GMT


It is returning me ffffffff. I also removed the '0666' from my open & nothing
changed...I am wondering did something change in ver 2.4 of the kernel from the
older versions for the file-handling procedures...I know f_ops structure
changed...

In article <[EMAIL PROTECTED]>,  says...
>
>In article <jsZJ6.6773$[EMAIL PROTECTED]>,
>k  <[EMAIL PROTECTED]> wrote:
>>I am looking for a sample User space program which I can adapt for my ioctl test
>>code...I have a char driver registered in /dev and I can see it when I do 
>>more /proc/devices. Now, I am trying to comeup with some code that runs in the
>>User Space and does two things..
>>->Open my device
>>-> send ioctls to it.
>>My sample code which runs like
>>open("/dev/plx",O_RDWR,0666) is failing to return me a pointer to my device...
>
>I assume by "failing to return me a pointer to my device" you mean
>it is returning an error?  If so, what's errno after the open call?
>
>Why do you have the 0666 argument? 
>
>--
>http://www.spinics.net/linux



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

Date: Tue, 08 May 2001 16:54:48 -0600
From: "D. Stimits" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Subject: Re: cache coherency, threads, SMP

Rik van Riel wrote:
> 
> D. Stimits wrote:
> 
> > In an effort to write more efficient threaded code (x86), and
> > considering cache thrashing, I'm interested in finding out
> > more about the cache coherency scheme used in 2.2 and 2.4
> > kernels. Is it a simple write-invalidate scheme?
> 
> > On a minor note, I'm curious how closely linux x86 SMP cache
> > schemes are to other x86 UNIX style systems?
> 
> Cache coherency between different CPUs is completely done in
> hardware (on x86). This means Linux and other Unices will be
> using the same cache coherency scheme ;)

I assume some of the motherboards capable of dual celeron do not have
the ability to follow direct cache-to-cache writes when one cpu cache is
shared with another and the first is modified relative to main memory?
Basically I'm wondering which, of the "oddball" x86 cpu's, including
celeron, thunderbird, duron, etc, cannot do an efficient cache-to-cache
update?

> 
> Btw, this is happening no a per-cacheline basis, using the MESI
> protocol between CPUs.

To improve performance, it would still be nice to know the exact size of
a cache line in order to keep two areas of global data from splitting up
ownership of a given cache line. Are all x86 cpu's using the same size
cache line? Is this 32 bytes, or some other known size (and if not is
there a way to find out through hardware detection)?

D. Stimits, [EMAIL PROTECTED]

> 
> --
> Rik
> --
> Virtual memory is like a game you can't win;
> However, without VM there's truly nothing to lose...
> 
> http://www.surriel.com/         http://distro.conectiva.com/
> 
> Send all your spam to [EMAIL PROTECTED] (spam digging piggy)

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

From: [EMAIL PROTECTED] ()
Subject: Re: looking for user space program example...
Date: Tue, 08 May 2001 22:57:45 -0000

In article <62_J6.6827$[EMAIL PROTECTED]>,
k  <[EMAIL PROTECTED]> wrote:

>It is returning me ffffffff.

Well that means the open failed.

>I also removed the '0666' from my open & nothing
>changed...I am wondering did something change in ver 2.4 of the kernel from the
>older versions for the file-handling procedures...I know f_ops structure
>changed...

What is errno set to after the open?

--
http://www.spinics.net/linux

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

Reply-To: "Rosimildo daSilva" <[EMAIL PROTECTED]>
From: "Rosimildo daSilva" <[EMAIL PROTECTED]>
Subject: How to unblocking a thread blocked on an accept() ( try 2 )
Date: Wed, 09 May 2001 00:25:21 GMT

Hi guys,

I have a thread blocked on an accept() call. I'd like to wake it up from
another thread. How do I do that ?

Under WIN32, I just close the socket, and the accept() returns with an
error code.

---
Rosimildo da Silva                  [EMAIL PROTECTED]
ConnectTel, Inc.                    Austin, TX -- USA
Phone : 512-338-1111                Fax : 512-918-0449
Company Page:     http://www.connecttel.com
Home Page:        http://members.nbci.com/rosimildo/



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

Subject: Re: STLport 4.0 & g++ 2.96
From: Steve Connet <[EMAIL PROTECTED]>
Date: Wed, 09 May 2001 02:15:58 GMT

[EMAIL PROTECTED] (Paul F. Kunz) writes:

> Steve Connet <[EMAIL PROTECTED]> writes:
> 
> > And like I said before, I heard it's almost next to impossible to
> > revert back to an older version of gcc (ie. 2.95) on a RH7.0 system
> > that has gcc 2.96 on it.
> > 
>    I've installed gcc 2.95.3 in /usr/local on my RH7.1 system and
> compiled, linked, and ran my C++ programs with it without problems.
> I use the STL that comes with gcc.

If I do that, how do I tell the compiler to look in /usr/local/lib and
/usr/local/include and NOT /usr/lib, /lib, and /usr/include ??

-- 
Steve Connet            Remove USENET to reply via email
[EMAIL PROTECTED]

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


** 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