Linux-Development-Apps Digest #392, Volume #7    Thu, 10 May 01 02:13:15 EDT

Contents:
  Re: why a thread running in a separate process on Linux? (sitazen)
  Re: Access to 0xD0000 - 0xDFFFF on ISA bus ("Norm Dresner")
  Re: What is low level programming ("Norm Dresner")
  Re: What is low level programming (Jim Cochrane)
  Re: Faster than strstr ("Bill Medland")
  Re: Faster than strstr ("Dann Corbit")
  Re: why a thread running in a separate process on Linux? ("Norman Black")
  Re: Adding file extension recursively ("Zoran Cutura")
  Java hogs keyboard in X (Christopher Wong)
  C++ Shared libraries on Linux - problem, HELP! (Billy Bob Jameson)
  writing to syslog (Steve Connet)
  swish++-5.06b and rh 7. (William Daffer)
  Re: Multiple processes using the curses library (Kaz Kylheku)
  Re: why a thread running in a separate process on Linux? (Eric P. McCoy)
  Re: How to get a number of processors (Eric P. McCoy)

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

From: [EMAIL PROTECTED] (sitazen)
Subject: Re: why a thread running in a separate process on Linux?
Date: Wed, 09 May 2001 18:37:42 GMT

On Wed, 09 May 2001 12:01:34 GMT, [EMAIL PROTECTED] (Lew Pitcher) wrote:
>
>One could even argue that the linux threading model is more efficient
>than threading models that make all threads 'belong to the same
>process as the main thread'.
>
>In the 'threads within process' model, there are two scheduling
>processes that must be satisfied: the process scheduler which picks
>between ready processes, and the thread scheduler which picks between
>ready threads in the ready process.
>
>In the linux 'threads are processes' model, you only need the process
>scheduler since, because 'threads are processes', thread scheduling
>_is_ process scheduling.
>

I always thought that when a process creates its first thread (besides its
initial main thread) that a separated 'manager thread' is also started for that
process. Is this not similar to a thread scheduler, at least in terms of
overhead?


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

From: "Norm Dresner" <[EMAIL PROTECTED]>
Subject: Re: Access to 0xD0000 - 0xDFFFF on ISA bus
Date: Wed, 09 May 2001 18:41:18 GMT

Holger <[EMAIL PROTECTED]> wrote in message
news:9dbpts$icv$[EMAIL PROTECTED]...
> Hi,
>
> I would like to know how to access the address range from 0xD0000 to
0xDFFFF
> (I/O Expansion ROM and PC JR Cartridge) on the ISA bus. As far as I
> understand it inb() and outb() can only access the address range up to
> 0x10000.
> A source example would be very helpful.
>
> Thanks in advance
>
> Holger
>

     See my reply in comp.arch.embedded


    Norm




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

From: "Norm Dresner" <[EMAIL PROTECTED]>
Subject: Re: What is low level programming
Date: Wed, 09 May 2001 18:51:52 GMT

Mayan <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> I was talking to some body who swers that C/C++ programming can be
> considered low level programming, since that C++ makes calles to low
> level functions.
>
> Anybody?

The reason that it's considered (by some) to be "low-level programming" is
that the range of atomic operations that you perform in it are relatively
primitive:
    arithmetic operations
    logical comparisons
    simple looping controls
    ...

There are languages which used to be called 4th generation and 5th
generation (I haven't see either of these terms in years) in which the
lowest level operations are relatively complex functions like
    search for the pattern xxx -- could be literal or "visual" or "auditory"
data
    replace yyy with zzz in this range of data
    find files that meet these criteria
    ...
Some of these are patterned after data-base operations and some are
"replacements" for whole (utility) programs.  The idea is that by
implementing complex operations as the "primitives" of the language,
programmers would be more productive than if they had to use operations that
were almost identical with the primitive machine instruction set.  --  Much
of the impetus for this was a series of studies in the 60's that claimed to
"prove" that programmer productivity could be measured in "lines of code per
hour/day" and that this measure was (almost) independent of the language
used, hence if each line of code was a complex operation, we'd get more
useful work out of each programmer.

I'm going to refrain from injecting (any more) of my own opinions on the
subject (although you might be able to infer some from the word choice in
the paragraphs above).

    Norm



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

From: [EMAIL PROTECTED] (Jim Cochrane)
Subject: Re: What is low level programming
Date: 9 May 2001 13:11:38 -0600

In article <clgK6.12551$[EMAIL PROTECTED]>,
Norm Dresner <[EMAIL PROTECTED]> wrote:
>Mayan <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]...
>> I was talking to some body who swers that C/C++ programming can be
>> considered low level programming, since that C++ makes calles to low
>> level functions.
>>
>> Anybody?
>

It depends on how you use it.  Since C and C++ include include mechanisms
(pointer manipulation, bit manipulation, etc.) that are needed for
low-level programming such as operating systems and device drivers, using C
or C++ for this type of programming is certainly low level (although there
are some things that can't be done in C, so switching to assembly language
would be necessary for these cases).

However, C and C++ are also used to write large applications, which usually
aren't considered low level.  So if you use C++ to write such an
application, you're not really doing low level programming.

On the other hand, there are languages that are better suited for writing
large applications, since they are essentially higher level than C++.
These include Smalltalk, Java, Eiffel, and the Lisp and functional language
variants.  So perhaps you could call writing a large app. in C++
medium-level programming. :-)
-- 
Jim Cochrane
[EMAIL PROTECTED]

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

Subject: Re: Faster than strstr
From: "Bill Medland" <[EMAIL PROTECTED]>
Crossposted-To: comp.lang.c.moderated,comp.lang.c
Date: 09 May 2001 19:26:04 GMT

Edward Rosten <[EMAIL PROTECTED]> wrote in article
<[EMAIL PROTECTED]>...
> > with http://www.cs.utexas.edu/users/best-ideas/string-searching I have
> 
> 
> This URL 404's. Do you have another?
> 
> cheers
> 
> -Ed
Try http://www.cs.utexas.edu/users/moore/best-ideas/string-searching 
-- 
comp.lang.c.moderated - moderation address: [EMAIL PROTECTED]

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

Subject: Re: Faster than strstr
From: "Dann Corbit" <[EMAIL PROTECTED]>
Crossposted-To: comp.lang.c.moderated,comp.lang.c
Date: 09 May 2001 19:26:14 GMT

"Chris Kern" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> On 08 May 2001 23:42:21 GMT, "Edward Rosten" <[EMAIL PROTECTED]> posted the
> following:
>
> >In article <[EMAIL PROTECTED]>, "David Rubin"
> ><[EMAIL PROTECTED]> wrote:
> >
> >> DB wrote:
> >>
> >> [snip - strstr not fast enough]
> >>> I found strchr() to be the fastest search available on the X86. This
> >>> became the front-end to my new search routine. The result is
> >>> strchrstr(), that uses a fast strchr() to find potential matches, and
> >>> then does a strncmp() on the remainder of the target string.
> >>
> >> ...or you can try a regex package.
> >
> >Surely, regex, which is more complex than strstr will be slower?
>
> It would depend on the algorithm used, wouldn't it?  I can imagine a
> brute-force string matching algorithm going slower than a regexp
> package which uses a better algorithm.


Even more so, it will be a function of the problem size.  If I have ten
character strings, then strstr() will probably do better than regexp().  If I
have thousand megabyte strings, I doubt if there is any contest.

Then again, why not try a web search to find stuff like this:
http://www.cs.purdue.edu/homes/stelo/pattern.html
--
C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
 "The C-FAQ Book" ISBN 0-201-84519-9
C.A.P. FAQ: ftp://cap.connx.com/pub/Chess%20Analysis%20Project%20FAQ.htm
-- 
comp.lang.c.moderated - moderation address: [EMAIL PROTECTED]

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

From: "Norman Black" <[EMAIL PROTECTED]>
Subject: Re: why a thread running in a separate process on Linux?
Date: Wed, 9 May 2001 12:44:26 -0700
Reply-To: "Norman Black" <[EMAIL PROTECTED]>

> In the 'threads within process' model, there are two scheduling
> processes that must be satisfied: the process scheduler which picks
> between ready processes, and the thread scheduler which picks between
> ready threads in the ready process.
>
> In the linux 'threads are processes' model, you only need the process
> scheduler since, because 'threads are processes', thread scheduling
> _is_ process scheduling.

Says who.
Define "process scheduling".

Scheduling an executable entity is done via priority. Just how that priority
is determined varies by system. A priority for an executable entity most
times is the sum of a "process priority" and "thread priority". Most systems
are dynamically adjusting the priority of individual executable entities as
things happen. You only need an "executable entity" scheduler, and this is
all I have ever seen.

All Linux threads are kernel scheduled (my statement assumes the use of the
"normal" Linux pthreads library). On Solaris for example they use a more
complicated pthreads model with M user threads multiplexed on N kernel
threads (LWP in Sun terminology). Scheduling here becomes complicated
because of the two layer model, and maybe this is why on Solaris 8 Sun
provides an alternative "simpler" (<- Sun's words) threads library that uses
a one to one threading model, which Linux uses, NT uses and others use.

--
Norman Black
Stony Brook Software
the reply, fubar => ix.netcom



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

From: "Zoran Cutura" <[EMAIL PROTECTED]>
Subject: Re: Adding file extension recursively
Date: Wed, 09 May 2001 11:26:06 +0200
Reply-To: [EMAIL PROTECTED]

Once upon a while "Rolf Magnus" <[EMAIL PROTECTED]> wrote:

> Chris wrote:
> 
>> if [ x`dd if=$1 bs=5 count=1 2> /dev/null` = xGIF89 ] ; then
>> exit 0
>> else
>> exit 1
>> fi
>> 
>> ... but I won't claim that this is the most efficient
>> implementation.
> 
> Or:
> [ x`head -c4 "$1"` = xGIF8 ]
> exit $?
> 
> This also works for gif87 files.
> 

That's fine guys, so lets write the one-liner for "rename all
file in directory tree that seem to have GIF-Format but do not
end in .gif to name.gif":
I think that grep is your friend within find actions!

find . -type f -exec grep -a -q "^GIF8[7,9].*" {} \; ! -iname "*.gif" \
-exec mv {} {}.gif \;

One could add a -fls or -fprint action right after the last
-exec action to have a list of files renamed written to a file.
Or add a simple -print to write that list to the terminal.

There is some risc left that a file contains a string matching
GIF8[7,9] at the beginning of a line other than the first line
in the file, this is left as a homework for anybody interessted.
:-)

-- 
Z ([EMAIL PROTECTED])
"LISP  is worth learning for  the profound enlightenment  experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days."   -- Eric S. Raymond

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

From: [EMAIL PROTECTED] (Christopher Wong)
Subject: Java hogs keyboard in X
Date: Wed, 09 May 2001 22:52:38 GMT

I am writing a custom window manager for a specific application. Don't
groan: you won't find it on Freshmeat. I know the world does not need
another window manager. Among other things, the window manager needs to
intercept certain keystrokes to act on them. I tried to do this by
intercepting MapRequest events and calling XSelectInput(display, w,
KeyPressMask) on each new window. I would then receive KeyPress events
in my event loop. But for some reason, this does not work with a
Java/Swing window. In desperation, I also tried XGrabKey but even this
does not catch a PrintScrn/SysRq keystroke.

Does anyone know why a Java app would hog a keyboard like this? Any
suggestions on how to get a SysRq KeyPress event when a Java frame has
focus? Thanks in advance.

Chris



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

From: Billy Bob Jameson <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.misc,comp.os.linux.development.system
Subject: C++ Shared libraries on Linux - problem, HELP!
Date: Wed, 09 May 2001 23:52:37 GMT



Hi.

For some time now I am struggling to understand what's wrong with my way
of building a shared library. Got a lot of answers from some ppl but
still.

Building a shared lib on UNIX is apparently a no-brainer. However, all
my attempts  end with "Segmentation fault" immediately after launching
the test program that uses the shared library. So far I found out it's
not because I use namespaces.

More precisely, gdb displays just:
(gdb) run
Starting program: /work/src/testbin/testbin/.libs/testbin
Program received signal SIGSEGV, Segmentation fault.
0x4000c1b6 in ?? ()
(gdb) bt
#0  0x4000c1b6 in ?? ()
#1  0x40002855 in ?? ()
#2  0x4001048f in ?? ()
#3  0x40002382 in ?? ()
#4  0x400020ae in ?? ()
(gdb)

This is all I get.

If there is anyone here willing to get my sources (two kdevelop
projects) compile them,  run them and tell me then where I was wrong,
he/she'll have my eternal gratitude.

Additional info:
RH 7.0 system upgraded from rpms to glibc 2.2.10


TIA
BB



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

Subject: writing to syslog
From: Steve Connet <[EMAIL PROTECTED]>
Date: Thu, 10 May 2001 01:19:41 GMT

I already know how to write to syslog daemon. I can even use LOG_USER
in the syslog function and tell /etc/syslog.conf to send the output to
another file.

The problem is other applications may also use LOG_USER and all output
from all applications using LOG_USER will go to the file specified in
/etc/syslog.conf

I guess the only way to have it write to a file ONLY by my app, is to
have my app write its own log file. This is simple and I've done it
before, but was just wondering.

In addition, is it better to have your app write to syslog or write to
its own logfile? I guess it depends on what's being logged and the
quantity? I'll be loggin logins and logoffs through my server app as
well as actions each user performs. The more I think about, the more I
think it should probably write to it's own logfile? What do you think?

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

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

Crossposted-To: comp.os.linux.redhat
Subject: swish++-5.06b and rh 7.
From: William Daffer <[EMAIL PROTECTED]>
Date: Thu, 10 May 2001 02:34:30 GMT


Has anyone been able to build this? I have the following error early
on in the compilation:

[root swish++-5.0b6]# make
g++ -DMOD_HTML -DMOD_MAIL -DSEARCH_DAEMON -DMULTI_THREADED -D_REENTRANT  -DLinux   -O3 
   -c -o conf_var.o conf_var.c
In file included from conf_var.h:32,
                 from conf_var.c:31:
fake_ansi.h:55: redefinition of default argument for `class _Distance'
/usr/include/g++-3/stl_iterator.h:88:   original definition appeared 
here
fake_ansi.h:55: redefinition of `struct iterator<_Category, _Tp, 
_Distance, _Pointer, _Reference>'
/usr/include/g++-3/stl_iterator.h:90: previous definition here
make: *** [conf_var.o] Error 1

My development configuation:

glibc-2.2-12
gcc-2.96-69
libstdc++-2.96-69
libstdc++-devel-2.96-69
compat-libstdc++-6.2-2.9.0.9

TIA

William Daffer
-- 
Outside of a dog a book is man's best friend. 
Inside of a dog it's too dark to read
                             Groucho Marx

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

From: [EMAIL PROTECTED] (Kaz Kylheku)
Crossposted-To: comp.os.linux.development.system
Subject: Re: Multiple processes using the curses library
Reply-To: [EMAIL PROTECTED]
Date: Thu, 10 May 2001 02:36:30 GMT

On Wed, 09 May 2001 16:14:25 +0100, Alex Brown (bee3_00)
<[EMAIL PROTECTED]> wrote:
>At the moment I am having difficulty in getting the two processes to share the
>terminal screen despite having non-overlapping subwindows.

That's probably because they have no concept of sharing. Both will write
to the terminal device, and their writes will get interleaved.

Your terminal is not a direct access array of characters, but rather a serial
output device whose cursor positioning is controlled by escape sequences. 
The device knows nothing about subwindows; they are just an illusion created
by sending the right sequence of characters.

If these sequences get mixed up from two sources, you will get a garbled 
screen.

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

Subject: Re: why a thread running in a separate process on Linux?
From: [EMAIL PROTECTED] (Eric P. McCoy)
Date: 10 May 2001 01:22:10 -0400

"Nils O. Selåsdal" <[EMAIL PROTECTED]> writes:

> Not excactly forking , cloning.. a little diffrence there. This is because
> linux doesnt have threading support in the kernel,

No, threading support in the kernel is implemented using clone().
Don't convey the impression this is userspace threading, because it's
not: it's real, preemptive multithreading, just sans some of the
features that POSIX threads are supposed to have.

-- 
Eric McCoy <[EMAIL PROTECTED]>
  "Knowing that a lot of people across the world with Geocities sites
absolutely despise me is about the only thing that can add a positive
spin to this situation."  - Something Awful, 1/11/2001

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

Crossposted-To: comp.os.linux.development.system
Subject: Re: How to get a number of processors
From: [EMAIL PROTECTED] (Eric P. McCoy)
Date: 10 May 2001 01:28:37 -0400

John Beardmore <[EMAIL PROTECTED]> writes:

> >  While it's certainly possible for an app to figure out
> >what other apps are doing, it's bad for it to base its behavior on any
> >of that information because it has _no idea_ what the other app is
> >doing.

> Pardon ?

Wow.  That makes no sense to me, either.

My best guess is that I meant to say: while app A may be able too how
much system resources app B is using, app A can't make any predictions
on how long those resources are going to be in use, what patterns
they're going to be following, and so on.  The kernel is still limited
in this respect, but it has a better chance of guessing, assuming some
heinously complicated logic, based on syscalls being used.

In fact, it might not be that tough, I just haven't thought about it
enough to have a solid guess.

> >If you can guarantee that your Magic Parallelizing App is going to be
> >the only process running at any given time,

> Well, the only process requiring significant resource.

> > then you can damn well
> >guarantee you'll have an operator smart enough to know how many CPUs
> >are in the machine (and how to tell your app about it).

> So anybody writing // apps can (has to!) afford a better class of
> operator ??

If they can afford a dedicated computer, they can afford to pay
someone $10 to explain to a group of people how to configure the
program properly.  I'm talking just about large bunches of computers,
here; for small numbers (say, <10) the programmer/admin can do it
himself.

> >  If you can't
> >guarantee that, then you need to leave process management up to the
> >kernel, which can understand the situation far better than any
> >individual app.

> If you know the circumstances in which the app will be run, why not
> give it an indication of the number of CPUs ?  Why give the operator
> something else they can get wrong ?

Because they won't.  If necessary, print up a bunch of labels and
stick them on front of the computers.  Still not a real great
solution, but at least it's no longer a platform-dependant one.

> >Seems like what you're _really_ advocating is some powerful process
> >management stuff in the kernel.

> No.  That would be the good long term solution.  What I'm advocating,
> or at least endorsing is a horrible bodge to give a better behaviour
> in a limited set of circumstances.

Ah, so we agree it's a bad thing.  I'll grant you it may sometimes be
necessary under certain conditions; my only original complaint was
that it seemed like a hack.

If we agree on that, we're settled.  I hope we meet up a year or so
down the road rewriting the Linux scheduler, or something.  Although
if you see my name in the project, you should probably tell Linus to
come over and personally kick my ass, as I have no idea how to even
begin programming a scheduler.

-- 
Eric McCoy <[EMAIL PROTECTED]>
  "Knowing that a lot of people across the world with Geocities sites
absolutely despise me is about the only thing that can add a positive
spin to this situation."  - Something Awful, 1/11/2001

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


** 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.apps 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-Apps Digest
******************************

Reply via email to