Linux-Development-Sys Digest #83, Volume #7 Sat, 21 Aug 99 22:14:12 EDT
Contents:
Re: Linux - Memory model / protection scheme ("nicolas.gasnier")
Re: Incorrect work of "signal" (BSD - style)? ([EMAIL PROTECTED])
Re: Shared Libraries: what is the linux equivalent of "dllimport" and "dllexport"
(Jonas Utterstrom)
Re: why not C++? (Paul D. Smith)
Re: Question about segments (Emile van bergen)
Re: X Windows developement (Tranceport)
Re: Shared Libraries: what is the linux equivalent of "dllimport" and "dllexport"
("Noam K")
Re: Shared Libraries: what is the linux equivalent of "dllimport" and "dllexport"
(Kaz Kylheku)
Re: Linux - Memory model / protection scheme ("Pizzi")
Re: Direct programming of /dev/eth device? (Andi Kleen)
Re: How to resolve the mismatch type definition ? (David Schwartz)
Re: Shared Libraries: what is the linux equivalent of "dllimport" and "dllexport"
(Josh Stern)
generating random numbers (stephen chan)
Re: [kernel] how to measure running time in nanosecond? (David Schwartz)
high speed floating point coprocessor
Re: Linux - Memory model / protection scheme (Ulrich Weigand)
----------------------------------------------------------------------------
From: "nicolas.gasnier" <[EMAIL PROTECTED]>
Subject: Re: Linux - Memory model / protection scheme
Date: Sat, 21 Aug 1999 20:04:54 +0200
Well, linux does what win 32 doesn't (or does randomly ;-) : it handles
processor
exceptions instead of ignoring them (almost) all. That is killing programs
that
makes wrong memory acces, or stack overflow, or unauthorised acces to
hardware registers, and never try to let programs continue.
--
+-------
| Blade Cox
| e-mail : [EMAIL PROTECTED]
| e-mail alternatif : [EMAIL PROTECTED]
homepage : http://perso.wanadoo.fr/blade
>How does Linux implement memory protection? All I know is that it is in a
>flat memory model, it uses page-level protection, but somehow uses much
more
>complete protection than Win32 does.
>Any information is appreciated.
> - Ed Pizzi
>
>
------------------------------
From: [EMAIL PROTECTED]
Subject: Re: Incorrect work of "signal" (BSD - style)?
Date: Sat, 21 Aug 1999 23:37:36 +0200
EugeneK wrote:
> Every book on Linux I read and manual page for signal state
> the default signal handler is automatically restored after first
> signal is cought.
> Why does not it work? I include <signal.h>, not <bsd/signal.h>,
> still the default handler does not restored.
>
> Eugene.
If you are using GNU, `#define _POSIX_SOURCE' before any `#include'
directive in your source to get `signal()' work as expected. This is
called `Feature Test Macros' and is discussed in the libc documentation.
But you should better use `sigaction()' which gives you more
flexibility.
Frank
------------------------------
From: Jonas Utterstrom <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Shared Libraries: what is the linux equivalent of "dllimport" and
"dllexport"
Date: Sat, 21 Aug 1999 21:12:17 GMT
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Kaz Kylheku) wrote:
> On 21 Aug 1999 11:11:14 GMT, Petter Reinholdtsen <[EMAIL PROTECTED]>
wrote:
> >[Noam K]
> >> Any ideas how this is done in Linux? are there different solutions
> >> for a.out and ELF libraries?
> >
> >You make all the functions not to be exported 'static'. All global
> >symbols are exported. I don't know any way to change this.
>
> Then why bother posting? You could be reading the GNU info on
> ``ld'' to find out how this is done.
>
Better to say that you don't know than posting incorrect answers. And
using static functions is one way to limit the exported functions from a
shared library. But a very limited way.
> The following might be useful:
>
> `--retain-symbols-file FILENAME'
> Retain *only* the symbols listed in the file FILENAME, discarding
> all others. FILENAME is simply a flat file, with one symbol name
> per line. This option is especially useful in environments (such
> as VxWorks) where a large global symbol table is accumulated
> gradually, to conserve run-time memory.
This is useful only when you are performing static linking. What he
wants is to avoid exporting internal functions and objects in his SHARED
library. See my answer in the other thread for more info on this.
/Jonas U
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
From: [EMAIL PROTECTED] (Paul D. Smith)
Crossposted-To: comp.os.linux.development.apps,comp.os.linux.misc
Subject: Re: why not C++?
Date: 20 Aug 1999 18:08:49 -0400
Reply-To: [EMAIL PROTECTED]
%% [EMAIL PROTECTED] (Randall Parker) writes:
rp> But if the compiler doesn't do the optimization the result is
rp> slower code.
Yes. Until the compiler is improved, etc.
Either way, except in very specific circumstances where the code _must_
be as fast as possible (drivers, very busy daemons, etc.) and I know
that this is what's slowing it down (see below) it's simply not worth
my effort to worry about it.
rp> For instance, some processor architectures can shift left faster
rp> than shifting right (or maybe I have that backward). So if you do
rp> your shifting always one way you are writing your code to be
rp> faster or slower for a particular processor architecture whether
rp> you are aware of this or not.
Exactly my point. In widely ported and portable code, these kinds of
things are unknowable and, in general, not very interesting as
efficiency increases anyway.
It's a rare, and probably pretty specialized, program that will see any
significant benefit by having its loops count down rather than up.
rp> You ought to start looking at the generated assembly on a couple
rp> of different architectures and see whether your carefree attitude
rp> isn't consistently costing you performance loss unnecessarily.
No thanks. I have much better things to do than compare the output of
Sun's compiler vs AIX's compiler vs. HP's compiler vs. Greenhill's
compiler vs. GCC on each of those platforms, etc. etc. worrying about
these kinds of optimization issues. I'm sure the results will just as
often as not be contradictory anyway.
As I mentioned above, it's a rare program where micro-optimizations like
this will even be noticeable. The vast majority of slow code is due to
algorithm design issues or other kinds of latency.
You should read the famous whitepaper "News Need Not Be Slow", by Geoff
Collyer and Henry Spencer. There're a lot of good nuggets for practical
and results-oriented optimization in there.
ftp://ftp.cs.toronto.edu/doc/programming/c-news.ps
I'm not saying that adopting habits that are more likely to lead to
efficient code is bad (I decrement where possible, and I also use lots
of temporary pointer variables instead of int indices, for example). I'm
just saying it's very likely not worth going back and re-editing code on
a whim.
--
===============================================================================
Paul D. Smith <[EMAIL PROTECTED]> Network Management Development
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
===============================================================================
These are my opinions---Nortel Networks takes no responsibility for them.
------------------------------
From: Emile van bergen <[EMAIL PROTECTED]>
Subject: Re: Question about segments
Date: Sat, 21 Aug 1999 22:53:00 +0000
On Thu, 19 Aug 1999, Tristan Wibberley wrote:
> Emile van bergen wrote:
>
> > The Pentium II, however, reintroduces this ugly concept, because
> > offsets are still 32-bit, but the CPU allows for a max. of 36 bits
> > of address space using the base pointer of the segment descriptor.
> > There's much discussion going on if Linux should be changed to
> > support the bigger address space, as the whole messy segment model
> > would need to be incorporated.
>
> It not really all that messy to do. You just limit it's use to
> mmapping (either files or anonymous). You just need to add 3 r/w data
> segment descriptors to the descriptor table and make a page directory
> for them.
Okay, just 3 extra constant descriptors into the GDT, just like for APM.
I wouldn't mind that, IMHO it'd be the right compromise.
> It can be used for more things (complex protection inside an app), but
> not many people need that - it's real usefulness is for making large
> amounts of data available at one time.
Yes, for example, segment-level protection allows boundaries between
protection domains at arbitrary points (just set the size of the
segment), whereas with paging, you could be wasting up to PAGE_SIZE-1
bytes per domain transition. But it's not that much of a big deal, it's
really not worth it.
So you're right about its proper use ;-).
--
M.vr.gr. / Best regards,
Emile van Bergen (e-mail address: [EMAIL PROTECTED])
This e-mail message is 100% electronically degradeable and produced
on a GNU/Linux system.
~
~
:wq
------------------------------
From: Tranceport <[EMAIL PROTECTED]>
Subject: Re: X Windows developement
Date: Fri, 20 Aug 1999 20:49:23 GMT
In article <7pkc2c$ag9$[EMAIL PROTECTED]>,
Dave Newton <[EMAIL PROTECTED]> wrote:
> Tranceport <[EMAIL PROTECTED]> wrote:
> > I have to develop Xaw (X athena widgets, i think)
>
> I gotta ask... why?!?!
(sigh) all right, all right...
I'm part of the xfree 4.0 development team for Linux.
I just joined and I'm a newbie.
gotta do stuff.
gotta learn how.
:)
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
From: "Noam K" <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Shared Libraries: what is the linux equivalent of "dllimport" and
"dllexport"
Date: Sun, 22 Aug 1999 01:08:36 +0300
First , thank you both.
My problem is still not solved however:
1. 'static' does not work since my source code is in more than one c file.
(As far as I know one file is scope of the static declaration so calls in
other c files that make my library will not see the functions as well)
2. using ld with`--retain-symbols-file' does only creates symbols defined in
a specified file. However, since `--retain-symbols-file' does *not*
discard undefined symbols, or symbols needed for relocations; if anyone
uses one of the 'hidden functions' (those not specified in the symbols file)
the linker will still find them...
Any more ideas?
Noam
------------------------------
From: [EMAIL PROTECTED] (Kaz Kylheku)
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Shared Libraries: what is the linux equivalent of "dllimport" and
"dllexport"
Date: Sat, 21 Aug 1999 22:55:47 GMT
On Sat, 21 Aug 1999 21:12:17 GMT, Jonas Utterstrom <[EMAIL PROTECTED]> wrote:
>Better to say that you don't know than posting incorrect answers. And
>using static functions is one way to limit the exported functions from a
>shared library. But a very limited way.
You are right, I screwed this one up! Apologies for the misleading info.
The --retain-symbols-file option doesn't affect the retention of dynamic
symbols. These are still there, and can be viewed with ``nm -D''.
------------------------------
From: "Pizzi" <[EMAIL PROTECTED]>
Subject: Re: Linux - Memory model / protection scheme
Date: Sat, 21 Aug 1999 19:34:07 -0400
thanks for your response. and the same to everyone else who replied to my
message. i don't want to waste space by sending individual thanks messages.
> ...every process can
> write to the complete shared address space, which includes the image
>of DOS (in the first MB), the 16-bit global heap, all loaded 16-bit
>modules, and all shared 32-bit modules (including KERNEL32, USER32,
>GDI32, ...) The only thing that a process cannot do is to corrupt
>memory belonging to *another* (32-bit) process ;-)
really? i thought Win9x used page-level protection, thus allowing a program
(application privalege level) to write only to other segments owned by other
application level pages, thus allowing an application to write anywhere,
just not to the OS's memory.
about Linux -- since it's in flat memory model, the only way to give each
process its own address space is by updating the page tables at each task
switch, right? is this what happens? wouldn't that be kinda slow?
thanks again,
- Ed Pizzi
------------------------------
From: Andi Kleen <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Direct programming of /dev/eth device?
Date: 21 Aug 1999 00:41:05 +0200
"Richard Krehbiel" <[EMAIL PROTECTED]> writes:
> I'm about to embark on a project that intends to translate a very
> proprietary in-house ethernet protocol into TCP/IP. My current research
> tells me that a DOS packet driver interface is capable of doing what I need,
> so I've been proceeding in that direction.
>
> But you know, I'd much prefer to do this on Linux.
>
> Can I get my hands dirty with ethernet devices? I need to program a
> specific ethernet address, I need to send and receive on a specific ethernet
> multicast address, and of obviously I need to send and receive packets.
Grab man-pages-1.24 and read packet(7) for send/receive. Changing the
local ethernet address in Linux is driver dependent, and few support it
directly. This could be always worked around by using promiscuous mode
(or perhaps abusing the cards multicast filter if it has one)
-Andi
--
This is like TV. I don't like TV.
------------------------------
From: David Schwartz <[EMAIL PROTECTED]>
Subject: Re: How to resolve the mismatch type definition ?
Date: Sat, 21 Aug 1999 17:33:49 -0700
I would remove the offending line in the non-system header file. So,
I'd axe line 79 of Xlib.h.
DS
Cute Panda wrote:
>
> Dear All,
>
> I'm using RedHat Linux 6.0 and MetroLink 1.2.4 Motif to do the porting of
> our product, now I
> come across a problem described as follows:
>
> /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include/stddef.h:255:
> conflicting types for `wchar_t'
> /usr/X11R6/include/X11/Xlib.h:79: previous declaration of `wchar_t'
>
> Anybody knows how to resolve it ? what directive should I define ?
> please help, thanks a lot!
------------------------------
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Shared Libraries: what is the linux equivalent of "dllimport" and
"dllexport"
From: [EMAIL PROTECTED] (Josh Stern)
Date: Sun, 22 Aug 1999 00:16:26 GMT
>Any more ideas?
I don't know if you described the complete situation and its constraints -
however one thought that occurs to me is that if your code is either C++
or C that compiles as C++, then you may be able to make use of the
flexible namespace facilities in C++ to wrap portions of the code
with conflicting symbols in different namespaces.
- Josh
------------------------------
From: stephen chan <[EMAIL PROTECTED]>
Subject: generating random numbers
Date: Sat, 21 Aug 1999 18:10:18 -0700
Hello:
I've got this short piece of code that generates random numbers.
=============================================
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int i;
int random_num;
srand((unsigned int)time(NULL));
for(i=0;i<100;i++)
{
random_num=1+(int) (10.0*rand()/(RAND_MAX+1.0));
printf("%d\t",random_num);
}
}
===============================================
It's suppose to generate random numbers between 1 to 10,
but after testing, it generates random numbers between 0 to 10.
What am I doing wrong?
Thanks
Stephen
------------------------------
From: David Schwartz <[EMAIL PROTECTED]>
Subject: Re: [kernel] how to measure running time in nanosecond?
Date: Sat, 21 Aug 1999 17:36:14 -0700
Use Linux-2.2.11 and then add Ulrich Windl's 'NANO' patches. You can
find them in PPSkit-0.7.1 available from the various ftp.kernel.org
mirrors in pub/linux/daemons/ntp/pps
You can then use 'ntp_gettime' to get a timespec, which has the time in
nanoseconds. Look in /usr/include/linux/timex.h
It won't do much unless you:
1) Have a Pentium or better processor.
2) Disable any powersaving features such as APM.
DS
"���ΪY" wrote:
>
> using do_gettimeofday & timeval just can measure in microseconds
>
> does there any patchs or methods help me to do this
>
> thanks in advance
>
> mail: [EMAIL PROTECTED]
------------------------------
From: <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.hardware,comp.os.linux.misc
Subject: high speed floating point coprocessor
Date: Sun, 22 Aug 1999 00:30:53 GMT
Would it be possible to utilize a 3dfx 3d-accelerator as
a high speed floating point coprocessor, not necessarily
for displaying anything?
-Jeff
================== Posted via CNET Linux Help ==================
http://www.searchlinux.com
------------------------------
From: [EMAIL PROTECTED] (Ulrich Weigand)
Subject: Re: Linux - Memory model / protection scheme
Date: 22 Aug 1999 03:00:51 +0200
"Pizzi" <[EMAIL PROTECTED]> writes:
>really? i thought Win9x used page-level protection, thus allowing a program
>(application privalege level) to write only to other segments owned by other
>application level pages, thus allowing an application to write anywhere,
>just not to the OS's memory.
Well, every Win32 process in Win9x has its own address space (page tables).
This means that you *cannot* modify another Win32 process' memory; you
simply cannot even *address* that memory using the page tables of your
address space ...
But, although every process has its own address space, the upper half
of that address space is shared, which means that although every process
has its own page tables, the OS sets the tables up so that within the
upper half of *any* address space, the same physical memory is mapped.
Inside this upper half lies e.g. KERNEL32.DLL, which is mapped into
all address spaces at address 0xBFF70000 (Win95). If you write to
these addresses in any address space, *all* address spaces see the
modification -- the same physical page is mapped into all address spaces.
Note that Win95 *relies* on this fact: KERNEL32.DLL uses its data
section as shared memory and assumes that it contains always the
same data, no matter from which process a KERNEL32 routine was called.
Furthermore, since a call to a KERNEL32 routine (CreateProcess, say) is
just a simple procedure call, *without* any privilege transition,
the KERNEL32 data section (which contains e.g. the list of all processes)
must be (and *is*) writable by user-mode code, from within any address
space, otherwise CreateProcess (and the other KERNEL32 routines)
couldn't do its job.
This has the interesting effect that any user-mode code can corrupt
the KERNEL32 data section. Since the same section is mapped into
all address spaces, this means that KERNEL32 doesn't work any longer
in *any* process in the system, at which point you are due a reboot ;-)
Now it is debatable whether KERNEL32 is indeed 'operating system'
code or not (after all, there *is* code running with supervisor privilege
in the system: the VMM and the VxDs -- although you still can corrupt
even VxD memory from user-mode code :-/), but this question is rather
pointless IMO.
Note that on Windows NT, you can also corrupt the KERNEL32 data
(and on Linux, you can corrupt libc data ...). There, however,
this only means that *your process* crashes, because every process
uses its private copy of KERNEL32 (or libc, for that matter).
>about Linux -- since it's in flat memory model, the only way to give each
>process its own address space is by updating the page tables at each task
>switch, right? is this what happens? wouldn't that be kinda slow?
Yes, this is what happens. But this happens also in Win95 (and NT) ...
--
Ulrich Weigand,
IMMD 1, Universitaet Erlangen-Nuernberg,
Martensstr. 3, D-91058 Erlangen, Phone: +49 9131 85-7688
------------------------------
** 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
******************************