Linux-Development-Sys Digest #97, Volume #8 Wed, 23 Aug 00 20:13:11 EDT
Contents:
Re: all threads in a process share the same pid? (Kaz Kylheku)
Re: "Best" x86 Linux C/C++ compiler?? (Robert Cox)
Re: all threads in a process share the same pid? (Kaz Kylheku)
Programming socket in the cycle ("Pliev")
Programming /dev/ttyS* in Unix ("Pliev")
Re: all threads in a process share the same pid? ([EMAIL PROTECTED])
Re: all threads in a process share the same pid? ([EMAIL PROTECTED])
Re: how to insert my protocol into the linux protocol stack? (Grant Edwards)
Re: Programming /dev/ttyS* in Unix (Grant Edwards)
color depth (Gee)
Re: all threads in a process share the same pid? (Kaz Kylheku)
Re: color depth ("John Weeks")
Re: color depth (Kevin Lacquement)
Linux driver module question (Ed Hudson)
Network Device Driver Question (Greg Parrott)
Re: color depth (Anita Lewis)
Re: all threads in a process share the same pid? ([EMAIL PROTECTED])
Re: Network Device Driver Question (Kaz Kylheku)
----------------------------------------------------------------------------
From: [EMAIL PROTECTED] (Kaz Kylheku)
Crossposted-To: comp.os.linux.development.apps
Subject: Re: all threads in a process share the same pid?
Reply-To: [EMAIL PROTECTED]
Date: Wed, 23 Aug 2000 17:53:43 GMT
On Tue, 22 Aug 2000 18:50:35 +0200, Mario Klebsch <[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] writes:
>
>>| This is wholey a matter of opinion. I mine, it makes much more sense
>>| for threads to share the current working directory. In particluar, if
>>| you call chdir() based on user input in one thread, the logical
>>| assumption is that the user wanted to change his working directory,
>>| not that he wanted to change it "just for this thread"
>
>>The change, however, would be an asyncronous change of context as it
>>affects other threads.
>
>Since it is the nature of threads to share their context, asny changes
>to it are the rule, not the exception.
Threads do not share all of their context. That is why a control change from
one thread to another is called a context switch.
--
Any hyperlinks appearing in this article were inserted by the unscrupulous
operators of a Usenet-to-web gateway, without obtaining the proper permission
of the author, who does not endorse any of the linked-to products or services.
------------------------------
From: [EMAIL PROTECTED] (Robert Cox)
Subject: Re: "Best" x86 Linux C/C++ compiler??
Date: 23 Aug 2000 17:58:55 GMT
H.W. Stockman ([EMAIL PROTECTED]) wrote:
: The main use would be for compiling
: memory-intensive floating point code, with some middling
: graphics.
: Currently I use Intel C/C++ 4.5 under Microsoft VC++ in
: Windows. I did numerous tests with gcc and egcs back in
: 1997 and early 1998, and generally found they produced
: slower executables than did the Intel compiler (by 20 to 50%).
Try http://www.goof.com/pcg/ - I found that it speeded up my
memory+float intensive programs by about 15% over "plain" gcc.
bob cox
------------------------------
From: [EMAIL PROTECTED] (Kaz Kylheku)
Crossposted-To: comp.os.linux.development.apps
Subject: Re: all threads in a process share the same pid?
Reply-To: [EMAIL PROTECTED]
Date: Wed, 23 Aug 2000 18:03:53 GMT
On Tue, 22 Aug 2000 18:57:33 +0200, Mario Klebsch <[EMAIL PROTECTED]> wrote:
>[EMAIL PROTECTED] (Kaz Kylheku) writes:
>
>>If you have only one choice, then making the CWD a thread attribute
>>is safer, because it minimizes unwanted interactions between
>>unrelated subsystems;
>
>If they are unrelated, why do you use a thread?
In a nontrivial multithreaded application, it's not uncommon to find localized
threads that are internal to the workings of a module. The internal threads of
one module are not related to the threads of another. Functions with global
side effects can cause unwanted interactions among modules that otherwise
do not directly interface in any way.
--
Any hyperlinks appearing in this article were inserted by the unscrupulous
operators of a Usenet-to-web gateway, without obtaining the proper permission
of the author, who does not endorse any of the linked-to products or services.
------------------------------
From: "Pliev" <[EMAIL PROTECTED]>
Subject: Programming socket in the cycle
Date: Wed, 23 Aug 2000 22:38:02 +0400
Hello All!
I have a problem. I am sorry, my questions is fool, but I am beginner in
Unix :((
I have created two simple programs, for testing TCP/IP connecting - server
and client.
This examples I am attaching to this message.
This examples is working correctly, but one cycle of transfers only.
I want, that the transfer implemented permanently, in a cycle.
But the server invokes "accept" and does "send" in reply to a call
"connect"
on the party of the client only.But function "connect" not working in cycle.
It calling one time only. In outcome a transfer take place one time only.
How I can to solve this problem?
Help me, if you can...
Examlpes:
file://Server---------------------------------------------------------------
======
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <sys/time.h>
#include <signal.h>
#include <arpa/inet.h>
#include <string.h>
#include <pthread.h>
#define PORTNUM 1500
struct servent *sp;
struct hostent *hp;
int skt,ns;
struct sockaddr_in server,client;
int pid;
char buf[80];
char transes[180]="The testing message for VK. 273-99-44";
pthread_t idTrasmit;
void *Trasmit(void *arg)
{
int addrlen;
bzero(&client,sizeof(client));
addrlen=sizeof(client);
if ((ns=accept(skt, (struct sockaddr *)&client,(socklen_t *)&addrlen))==-1)
{
perror("Accept fail");
exit(1);
}
fprintf(stderr,"Client = %s\n",inet_ntoa(client.sin_addr));
int nbytes;
int fout;
close(skt);
send(ns,transes,sizeof(transes),0);
printf("Message sended\n");
close(ns);
} file://end transmit
main(int argc, char *argv[])
{
int nport;
nport=PORTNUM;
nport=htons((u_short)nport);
printf("The programm Testing Server TCP/IP for Vk\n");
printf("Copyleft C Dr.Pliev 23.08.2000\n");
if ((skt=socket(AF_INET, SOCK_STREAM, 0))==-1)
{
perror("Error creating socket");
exit(1);
}
printf("Socket created, ID=%d\n",skt);
bzero(&server, sizeof (server));
server.sin_family=AF_INET;
server.sin_addr.s_addr=INADDR_ANY;
server.sin_port=nport;
if (bind(skt,(struct sockaddr *)&server,sizeof(server))==-1)
{
perror("Error of bind");
exit(1);
}
printf("Bind OK\n");
printf("Server ready:%s\n",inet_ntoa(server.sin_addr));
if (listen(skt,5)==-1)
{
perror("Error call listen");
exit(1);
}
printf("Listen OK\n");
pthread_create (&idTrasmit, NULL,Trasmit, NULL);
for(;;);
return 0;
}
// Client ---------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <sys/time.h>
#include <signal.h>
#include <arpa/inet.h>
#include <string.h>
#define PORTNUM 1500
main(int argc, char *argv[])
{
int skt;
int pid;
int i,j;
char transes[180];
struct sockaddr_in server;
struct hostent *hp;
double num;
int dec, sign, ndig =0;
char *str;
printf("The programm Client TCP/IP for Vk\n");
printf("Copyleft C Dr.Pliev 23.08.2000\n");
if((hp=gethostbyname(argv[1]))==0)
{
perror("gethostbyname error");
exit(1);
}
bzero(&server, sizeof (server));
bcopy(hp->h_addr,&server.sin_addr,hp->h_length);
server.sin_family=hp->h_addrtype;
server.sin_port=htons(PORTNUM);
if ((skt=socket(AF_INET, SOCK_STREAM, 0))==-1)
{
perror("Error creating socket");
exit(1);
}
printf("Socket created, ID=%d\n",skt);
fprintf(stderr,"Address Client = %s\n",inet_ntoa(server.sin_addr));
if (connect(skt,(struct sockaddr *)&server,sizeof(server))==-1)
{
perror("Connect errror");
exit(1);
}
for(;;)
{
if(recv(skt,&transes,sizeof(transes),0)>0)
{
printf("%s\n",transes);
num=(double)transes[7];
str = fcvt(num, ndig, &dec, &sign);
printf(" %s\n",str);
}
close (skt);
}
}
------------------------------
From: "Pliev" <[EMAIL PROTECTED]>
Subject: Programming /dev/ttyS* in Unix
Date: Wed, 23 Aug 2000 22:38:37 +0400
Hello!
Do you can to say to me, how in Unix (Linux) can to program COM ports
(/dev/ttyS*).
Which functions I must to use? I programmed in Win32 earlier, and used
function CreateFile,
WriteFile etc. Which analogs this functions using in Unix. I want to
program a information
interchange for modem.
If you can,send to me please a simple example on C.
Thanks!
------------------------------
From: [EMAIL PROTECTED]
Subject: Re: all threads in a process share the same pid?
Crossposted-To: comp.os.linux.development.apps
Date: Wed, 23 Aug 2000 19:51:21 GMT
In comp.os.linux.development.apps Mario Klebsch <[EMAIL PROTECTED]> wrote:
> IMHO a program should only call chdir, if it is explicitly ordered by
> the user to do so. Although it might be usefill to circumvent some
> limit, IMHO this does not jutify a process to change its current
> working directory.
There is one place where it's commonly done, in tree walking
functions. It's opional in ftw(), and I belive it's also selectable in
fts_open(). So it shouldn't be done in libraries, but there are cases
where it is done without asking the user.
--
Matt Gauthier <[EMAIL PROTECTED]>
------------------------------
From: [EMAIL PROTECTED]
Subject: Re: all threads in a process share the same pid?
Crossposted-To: comp.os.linux.development.apps
Date: Wed, 23 Aug 2000 19:55:13 GMT
In comp.os.linux.development.apps Kaz Kylheku <[EMAIL PROTECTED]> wrote:
> Threads do not share all of their context. That is why a control change from
> one thread to another is called a context switch.
Right, they're _supposed_ to share it, and don't. Switching threads
will always require a context switch, because you need to change the
value of registers. If you want the uid/gid/cwd to also change, you
want a different process, not a thread.
--
Matt Gauthier <[EMAIL PROTECTED]>
------------------------------
From: [EMAIL PROTECTED] (Grant Edwards)
Subject: Re: how to insert my protocol into the linux protocol stack?
Date: Wed, 23 Aug 2000 20:04:40 GMT
In article <[EMAIL PROTECTED]>, Mario Klebsch wrote:
>[EMAIL PROTECTED] (Grant Edwards) writes:
>
>>You just call dev_add_pack() with a pointer to a struct
>>containing the Etherenet protocol number and a pointer to a
>>callback routine to be called when packets of that type are
>>received.
>
>And how is the other side done, connecting my own protocol to
>socket(2)?
Darned good question. I've never hooked up a new protocol to
the user end of things. There are several fields in the struct
that's passed to dev_add_pack() that leave as NULL, and I
forget what they do -- you might want take a look at those.
--
Grant Edwards grante Yow! Psychoanalysis?? I
at thought this was a nude
visi.com rap session!!!
------------------------------
From: [EMAIL PROTECTED] (Grant Edwards)
Subject: Re: Programming /dev/ttyS* in Unix
Date: Wed, 23 Aug 2000 20:06:30 GMT
In article <[EMAIL PROTECTED]>, Pliev wrote:
>Do you can to say to me, how in Unix (Linux) can to program COM
>ports (/dev/ttyS*).
http://www.linuxdoc.org/HOWTO/Serial-Programming-HOWTO.html
--
Grant Edwards grante Yow! My forehead feels
at like a PACKAGE of moist
visi.com CRANBERRIES in a remote
FRENCH OUTPOST!!
------------------------------
From: Gee <[EMAIL PROTECTED]>
Crossposted-To: linux.redhat.misc,comp.os.linux.development.apps,linux.redhat.devel
Subject: color depth
Date: Wed, 23 Aug 2000 16:12:48 -0400
Hi, does anyone know how the set the display color to 16 or 32 bit
color?? I'm trying to allocate some colors using code and it's giving
me errors saying that it cant store to colormap, I think it might be the
color mode I have it in...
please help.
TIA
Gee
------------------------------
From: [EMAIL PROTECTED] (Kaz Kylheku)
Crossposted-To: comp.os.linux.development.apps
Subject: Re: all threads in a process share the same pid?
Reply-To: [EMAIL PROTECTED]
Date: Wed, 23 Aug 2000 20:17:16 GMT
On Wed, 23 Aug 2000 19:55:13 GMT, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>In comp.os.linux.development.apps Kaz Kylheku <[EMAIL PROTECTED]> wrote:
>> Threads do not share all of their context. That is why a control change from
>> one thread to another is called a context switch.
>
>Right, they're _supposed_ to share it, and don't. Switching threads
>will always require a context switch, because you need to change the
>value of registers.
I don't know what threads you are talking about now, but POSIX threads have a
lot more context than just registers. They have their own signal mask and set
of pending signals, their own attributes like priority, and their own thread
ID. None of these attributes are necessarily embodied in the CPU registers, but
rather are typically maintained by a kernel. Merely changing the values of
registers won't necessarily tell the system that you are a different thread.
In Linux, the thread descriptor in the kernel can carry a distinct current
working directory, user ID, signal handler set, file descriptor table and so
on. The current context is determined by the value of the global variable
``current'' (which is processor-specific under SMP). You can mess with
registers in user space and it won't do anything to the current pointer
in the kernel.
>If you want the uid/gid/cwd to also change, you
>want a different process, not a thread.
No that is not what I *want*. That is just an undesirable workaround to get
around limitations in brain-damaged standard interface.
What I *want* is an intelligently designed system interface, which Linux
can provide.
------------------------------
From: "John Weeks" <[EMAIL PROTECTED]>
Crossposted-To: linux.redhat.misc,comp.os.linux.development.apps,linux.redhat.devel
Subject: Re: color depth
Date: Wed, 23 Aug 2000 20:25:06 GMT
I believe there is a -bpp parameter for startx - e.g. -bpp24 for a 24 bit
bit plane. If its not for startx, it goes someplace in that world.
"Gee" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> Hi, does anyone know how the set the display color to 16 or 32 bit
> color?? I'm trying to allocate some colors using code and it's giving
> me errors saying that it cant store to colormap, I think it might be the
>
> color mode I have it in...
>
> please help.
>
> TIA
>
> Gee
>
------------------------------
From: Kevin Lacquement <[EMAIL PROTECTED]>
Crossposted-To: linux.redhat.misc,comp.os.linux.development.apps,linux.redhat.devel
Subject: Re: color depth
Date: Wed, 23 Aug 2000 21:18:08 GMT
John Weeks wrote:
>
> I believe there is a -bpp parameter for startx - e.g. -bpp24 for a 24 bit
> bit plane. If its not for startx, it goes someplace in that world.
The full command line is "startx -- -bpp 24". The "--" tells the startx
script to send any later options to the X app, instead of to the startx
script.
Once you determine the proper settings, change the defaults in
/etc/X11/something (can't remember the name off the top of my head).
Just go to that directory and type "man *"; it will give you some "no
such man page" errors, but one of them will tell you how to change your
default colour depth.
Cheers,
Kevin
------------------------------
From: Ed Hudson <[EMAIL PROTECTED]>
Subject: Linux driver module question
Date: Wed, 23 Aug 2000 18:27:23 -0400
I am writing a kernel module driver for a custom PCI based DSP board.
The board needs access to physical memory locations. I am using
virt_to_phys() to translate the addresses, but I believe I need to
implement a locking mechanism so that the locations I refer to are not
swapped. Does any have any suggestions on how I may go about doing
this? Any links to reference materials or example drivers would be
much appreciated.
Thanks,
Ed Hudson
------------------------------
From: Greg Parrott <[EMAIL PROTECTED]>
Subject: Network Device Driver Question
Date: Wed, 23 Aug 2000 18:45:26 -0400
Reply-To: [EMAIL PROTECTED]
I have a couple of questions relating to network device drivers:
1) is there a mechanism for notifying the upper layers that the link level is
gone (detected loss of light, loss of signal, missing cable, etc.)? Do I just
set tbusy until things return to normal?
2) We are building an ASIC that will implement the TCP/IP stack in silicon. I
need to be able to write a device driver that will allow both a hardware stack
and the existing software stack to coexist. Do I simply replace the existing
"socket" calls in the struct proto to do a bit of packet snooping and determine
whether to forward to the traditional stack or route directly to my hardware?
Thanks!
--
Greg Parrott
Lucent Technologies
Optical Area Networking
(919) 838-6095
mailto:[EMAIL PROTECTED]
http://www.opticalareanetworks.com
------------------------------
From: [EMAIL PROTECTED] (Anita Lewis)
Crossposted-To: linux.redhat.misc,comp.os.linux.development.apps,linux.redhat.devel
Subject: Re: color depth
Reply-To: [EMAIL PROTECTED]
Date: Wed, 23 Aug 2000 22:45:53 GMT
On Wed, 23 Aug 2000 21:18:08 GMT, Kevin Lacquement wrote:
>John Weeks wrote:
>>
>> I believe there is a -bpp parameter for startx - e.g. -bpp24 for a 24 bit
>> bit plane. If its not for startx, it goes someplace in that world.
>
>The full command line is "startx -- -bpp 24". The "--" tells the startx
>script to send any later options to the X app, instead of to the startx
>script.
>
>Once you determine the proper settings, change the defaults in
>/etc/X11/something (can't remember the name off the top of my head).
>Just go to that directory and type "man *"; it will give you some "no
>such man page" errors, but one of them will tell you how to change your
>default colour depth.
>
>Cheers,
>Kevin
The file is /etc/X11/XF86Config. In the Screen Section you put the default
color depth:
Section "Screen"
Driver "Accel"
Device "Primary Card"
Monitor "Primary Monitor"
DefaultColorDepth 16 <-------------here is where it goes********
SubSection "Display"
Depth 8
Modes "800x600" "1024x768" "640x480"
EndSubSection
SubSection "Display"
Depth 16
Modes "800x600" "1024x768" "640x480"
EndSubSection
<followed by more SubSections>
------------------------------
From: [EMAIL PROTECTED]
Subject: Re: all threads in a process share the same pid?
Crossposted-To: comp.os.linux.development.apps
Date: Wed, 23 Aug 2000 23:19:21 GMT
In comp.os.linux.development.apps Kaz Kylheku <[EMAIL PROTECTED]> wrote:
> I don't know what threads you are talking about now, but POSIX threads have a
> lot more context than just registers. They have their own signal mask and set
Doh, you're right.
> What I *want* is an intelligently designed system interface, which Linux
> can provide.
This is _STILL_ an open question. So far all you've pointed out is
that you like every thread to have its own working directory. You also
agree that there are situations which make that undesirable. Fine.
That _doesn't_ solve the shared pid issue. Nor is it more
"intelligent" than the posix model. You continue to make it sound as
if the Posix comitee cooked this up in their spare time, without
knowing anything about the problem.
If you want LinuxThreads, fine. You, Linus, and the rest of the kernel
developers take them and be happy. But don't continue to call people
who think they should work the same as threads on BSD, Solaris, NT,
etc stupid.
The bottom line is that to date, noone has put forward a single
compelling technical reason why LinuxThreads are superior to Posix
ones. And, I'm sorry, but the fact that you'd rather use
pthread_create() to make new processes instead of fork() is _not_
convincing.
--
Matt Gauthier <[EMAIL PROTECTED]>
------------------------------
From: [EMAIL PROTECTED] (Kaz Kylheku)
Subject: Re: Network Device Driver Question
Reply-To: [EMAIL PROTECTED]
Date: Wed, 23 Aug 2000 23:45:59 GMT
On Wed, 23 Aug 2000 18:45:26 -0400, Greg Parrott <[EMAIL PROTECTED]> wrote:
>I have a couple of questions relating to network device drivers:
>
>1) is there a mechanism for notifying the upper layers that the link level is
>gone (detected loss of light, loss of signal, missing cable, etc.)? Do I just
>set tbusy until things return to normal?
The tbusy flag is intended for flow control; it means the driver is busy
transmitting. If the hardware is down, it's not transmit busy, it's kaput. :)
If you set tbusy, you cause packets to be backlogged in the transmit queue.
This is probably not what you want, unless the condition is very transient.
When the data link is restored, do you want to transmit old packets? Consider
dropping the packets instead and rack up the transmission errors counter.
Otherwise after a very lengthy down time, you risk sending stale packets
to the network.
--
Any hyperlinks appearing in this article were inserted by the unscrupulous
operators of a Usenet-to-web gateway, without obtaining the proper permission
of the author, who does not endorse any of the linked-to products or services.
------------------------------
** 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
******************************