niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » Unix internals
Are Device Drivers Reentrant -- or Daemons?
Post new topic   Reply to topic Page 1 of 4 [50 Posts] View previous topic :: View next topic
Goto page:  1, 2, 3, 4 Next
Author Message
toby
*nix forums addict


Joined: 01 Jul 2005
Posts: 87

PostPosted: Thu Feb 16, 2006 5:18 am    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

James Harris wrote:
Quote:
"Chris Thompson" <cet1@cus.cam.ac.uk> wrote in message
news:dsqct8$q1r$1@gemini.csx.cam.ac.uk...
In article <dsl62m$1hvr$1@gavrilo.mtu.ru>,
Maxim S. Shatskih <maxim@storagecraft.com> wrote:
I'm not sure what 'reentrant' means here. AFAIK a program code
segment
is usually reentrant in that it cannot normally be written to - so

I'm against the whole word of ''reentrant". It is, in fact, something
from the
old time of MS-DOS add-ons which tried to do multitasking from this
pathetic
OS.

MS-DOS? That's practically yesterday! We were talking about
"reeentrant" and
"serially reusable" load modules back in OS/360, and it probably
wasn't a
new term then.

That's where I first came across the term. It was a long time ago. IIRC
it would apply to any module that did not modify part of itself.

Before stacks became an architectural commonplace, subroutine linkage
conventions (typically of the 'self-modifying' type, such as storing
the link address in a fixed location[1]) often precluded re-entrancy
and recursion by default.

As other posters point out, a stack answers both problems by providing
storage for state and return link that is local to any activation.

[1] e.g. http://www.cs.clemson.edu/~mark/subroutines/pdp8.html
Back to top
toby
*nix forums addict


Joined: 01 Jul 2005
Posts: 87

PostPosted: Thu Feb 16, 2006 5:17 am    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

James Harris wrote:
Quote:
"Chris Thompson" <cet1@cus.cam.ac.uk> wrote in message
news:dsqct8$q1r$1@gemini.csx.cam.ac.uk...
In article <dsl62m$1hvr$1@gavrilo.mtu.ru>,
Maxim S. Shatskih <maxim@storagecraft.com> wrote:
I'm not sure what 'reentrant' means here. AFAIK a program code
segment
is usually reentrant in that it cannot normally be written to - so

I'm against the whole word of ''reentrant". It is, in fact, something
from the
old time of MS-DOS add-ons which tried to do multitasking from this
pathetic
OS.

MS-DOS? That's practically yesterday! We were talking about
"reeentrant" and
"serially reusable" load modules back in OS/360, and it probably
wasn't a
new term then.

That's where I first came across the term. It was a long time ago. IIRC
it would apply to any module that did not modify part of itself.

Before stacks became an architectural commonplace, subroutine linkage
conventions (typically of the 'self-modifying' type, such as storing
the link address in a fixed location[1]) often precluded re-entrancy
and recursion by default.

As other posters point out, a stack answers both problems by providing
storage for state and return link that is local to any activation.

[1] e.g. http://www.cs.clemson.edu/~mark/subroutines/pdp8.html
Back to top
toby
*nix forums addict


Joined: 01 Jul 2005
Posts: 87

PostPosted: Thu Feb 16, 2006 5:07 am    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

James Harris wrote:
Quote:
"Chris Thompson" <cet1@cus.cam.ac.uk> wrote in message
news:dsqct8$q1r$1@gemini.csx.cam.ac.uk...
In article <dsl62m$1hvr$1@gavrilo.mtu.ru>,
Maxim S. Shatskih <maxim@storagecraft.com> wrote:
I'm not sure what 'reentrant' means here. AFAIK a program code
segment
is usually reentrant in that it cannot normally be written to - so

I'm against the whole word of ''reentrant". It is, in fact, something
from the
old time of MS-DOS add-ons which tried to do multitasking from this
pathetic
OS.

MS-DOS? That's practically yesterday! We were talking about
"reeentrant" and
"serially reusable" load modules back in OS/360, and it probably
wasn't a
new term then.

That's where I first came across the term. It was a long time ago. IIRC
it would apply to any module that did not modify part of itself.

Before stacks became commonplace, architectural subroutine linkage
conventions (typically of the 'self-modifying' type, such as storing
the link address in a fixed location[1]) often precluded re-entrancy
and recursion except through explicit emulation of a stack.

[1] e.g. http://www.cs.clemson.edu/~mark/subroutines/pdp8.html
Back to top
toby
*nix forums addict


Joined: 01 Jul 2005
Posts: 87

PostPosted: Thu Feb 16, 2006 4:37 am    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

Matthias Bethke wrote:
Quote:
begin followup to Paul Barker in comp.unix.programmer:
In linux (at least in my kernel) the folder "block" at the
root of the source tree contains all the generic block device stuff.
There may also be some good docs included with the kernel source.

There's a pretty good book by O'Reilly on Linux device drivers from
kernel 2.0 to 2.4, available on dead trees as well as free hypertext:
http://www.xml.com/ldd/chapter/book/

The 3rd edition covers 2.6: http://lwn.net/Kernel/LDD3/

Quote:

cheers!
Matthias
--
end
Back to top
Andrew Gabriel
*nix forums Guru


Joined: 19 Feb 2005
Posts: 454

PostPosted: Wed Feb 15, 2006 11:47 pm    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

In article <43F3B5B7.3080400@acm.org>,
Nick Roberts <nick.roberts@acm.org> writes:
Quote:

I am not an expert on pthreads, but my impression is that this facility
is really rather limited. I have heard that you cannot use the semaphore
facility without running as root, and that you are limited to 32 semaphores.

That might be a feature of some rather sad (and probably
not standards conforming) implementation, but it's certainly
not inherent in pthreads.

--
Andrew Gabriel
Back to top
Maxim S. Shatskih
*nix forums addict


Joined: 02 Apr 2005
Posts: 55

PostPosted: Wed Feb 15, 2006 11:21 pm    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

Quote:
do you mean situations that might be considered 'overkill' (e.g. a video
game where every moving object has a thread, so requiring hundreds or
thousands of threads)?

I mean overkill. For instance, using thread instead of the good old nonblocking
socket :)

Quote:
While I have the attention of Windows expert, I'd also like to ask about
the Win32 memory model.

Very similar to UNIX one. The kernel even supports fork(), which is used in
Microsoft Interix (UNIX emulation layer for Windows, rather rich).

Quote:
How should a full (generational) garbage collection scheme be
approached?

This is .NET, and not Windows. The details of .NET garbage collector can be
found on msdn.microsoft.com - just google for "CLR garbage collector" or such.

Quote:
reached. Can this be done under Win32?

Yes it can. No my area of expertise though (it is .NET), but well-documented.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
Back to top
Nick Roberts
*nix forums beginner


Joined: 12 Feb 2006
Posts: 5

PostPosted: Wed Feb 15, 2006 11:14 pm    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

Maxim S. Shatskih wrote:

Quote:
I'm surprised by your answer. Can you _name the exact Win32 API routines by
Microsoft_ which do not support multithreading?

Well, no I cannot, and I have to concede defeat as such :-)

Quote:
Stupid ancient UNIXen - do not. Good UNIXen - do, and have pthreads
implementation mapped to real kernel threads (like modern Linux does).

I am not an expert on pthreads, but my impression is that this facility
is really rather limited. I have heard that you cannot use the semaphore
facility without running as root, and that you are limited to 32 semaphores.

Quote:
Depends on programmer skills in fact. I use threads in Windows in real-world
projects since around 1996, and never had any issues with them, so are the
people I was working with.

You really never had /any/ issues with them?

Quote:
Abusing threads (using a thread when there is
no real need in it) - yes, this is a reality Smile

I'm interested in this point. When you say "using a thread when there is
no real need", do you mean something really daft (e.g. thread B cannot
start any of its work until thread A has completed all of its work) or
do you mean situations that might be considered 'overkill' (e.g. a video
game where every moving object has a thread, so requiring hundreds or
thousands of threads)?

I'm curious about this, because there are programming languages that
could be implemented in a way that tends to use lots of threads, even
when sometimes they are not really necessary. For example, a (modified)
Smalltalk implementation might implement every object as a thread, apart
from some optimisation for primitive operations.

While I have the attention of Windows expert, I'd also like to ask about
the Win32 memory model. I have always found it confusing as to which
parts of the map correspond to what, and how efficient memory management
should be achieved (at the machine code level, not C).

How should a full (generational) garbage collection scheme be
approached? Remember that full GC requires that blocks can be moved
around in memory at any time (to make a contiguous space for a new
allocation). It has to be thread-safe, and it has to be able to cope
with lots of small blocks mixed with a few large blocks. It must be 100%
non-leaking, and it must behave gracefully when memory limitations are
reached. Can this be done under Win32?

Sorry to go off topic here, but I'm eager to take the opportunity!

Thanks in advance.

--
Nick Roberts
Back to top
50295@web.de
*nix forums beginner


Joined: 09 Feb 2005
Posts: 32

PostPosted: Wed Feb 15, 2006 2:34 pm    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

Brian Inglis wrote:
Quote:
No, they would be device commands and responses.
Some organizations (IBM at least) consider any low level code below
the architectural interface (e.g. on an ethernet card or disk drive)
to be microcode, as opposed to the more widespread view of microcode
as hardwired code used to execute architectural instructions within a
CPU.

Thanks Brian. I'm now of the view that device driver commands to the
controller are not microcode -- at least in the case of memory-mapped
IO, since it by definition does not distinguish between controller
registers and memory locations.
Back to top
Brian Inglis
*nix forums beginner


Joined: 16 Feb 2005
Posts: 22

PostPosted: Wed Feb 15, 2006 11:55 am    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

On 14 Feb 2006 18:07:26 -0800 in comp.unix.internals, "Olumide"
<50295@web.de> wrote:

Quote:
Rather than start a new thread, I though it better to add a question
here since the thread has already gone a bit OT alteady Wink (by the
way, thanks to everyone for the naswers).

Just a minor point: I was pondering on the nature of the "conversation"
(or should I say instructions) the driver has with the controller. Is
it correct to term these commands microcode?

No, they would be device commands and responses.
Some organizations (IBM at least) consider any low level code below
the architectural interface (e.g. on an ethernet card or disk drive)
to be microcode, as opposed to the more widespread view of microcode
as hardwired code used to execute architectural instructions within a
CPU.

--
Thanks. Take care, Brian Inglis Calgary, Alberta, Canada

Brian.Inglis@CSi.com (Brian[dot]Inglis{at}SystematicSW[dot]ab[dot]ca)
fake address use address above to reply
Back to top
50295@web.de
*nix forums beginner


Joined: 09 Feb 2005
Posts: 32

PostPosted: Wed Feb 15, 2006 2:07 am    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

Rather than start a new thread, I though it better to add a question
here since the thread has already gone a bit OT alteady Wink (by the
way, thanks to everyone for the naswers).

Just a minor point: I was pondering on the nature of the "conversation"
(or should I say instructions) the driver has with the controller. Is
it correct to term these commands microcode?

Thanks,

- Olumide
Back to top
Maxim S. Shatskih
*nix forums addict


Joined: 02 Apr 2005
Posts: 55

PostPosted: Wed Feb 15, 2006 1:02 am    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

Quote:
There are a few, I think, but they're not what I'd call "Core APIs". The
ImageHlp library doesn't support multi-threading.

Is it documented? Can I use apartment threading there - i.e. many threads, but
the entity is only used by the thread which created it?

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
Back to top
James Harris
*nix forums beginner


Joined: 07 Jun 2005
Posts: 8

PostPosted: Tue Feb 14, 2006 10:04 pm    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

"Chris Thompson" <cet1@cus.cam.ac.uk> wrote in message
news:dsqct8$q1r$1@gemini.csx.cam.ac.uk...
Quote:
In article <dsl62m$1hvr$1@gavrilo.mtu.ru>,
Maxim S. Shatskih <maxim@storagecraft.com> wrote:
I'm not sure what 'reentrant' means here. AFAIK a program code
segment
is usually reentrant in that it cannot normally be written to - so

I'm against the whole word of ''reentrant". It is, in fact, something
from the
old time of MS-DOS add-ons which tried to do multitasking from this
pathetic
OS.

MS-DOS? That's practically yesterday! We were talking about
"reeentrant" and
"serially reusable" load modules back in OS/360, and it probably
wasn't a
new term then.

That's where I first came across the term. It was a long time ago. IIRC
it would apply to any module that did not modify part of itself.
Back to top
Nicholas Sherlock
*nix forums addict


Joined: 02 Mar 2005
Posts: 71

PostPosted: Mon Feb 13, 2006 11:31 pm    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

Maxim S. Shatskih wrote:
Quote:
Please note where and when the Win32 APIs are not thread-safe.
Maxim, I get the impression that you know a lot about the Win32 API, so
I'm surprised by your question.

I'm surprised by your answer. Can you _name the exact Win32 API routines by
Microsoft_ which do not support multithreading?

There are a few, I think, but they're not what I'd call "Core APIs". The
ImageHlp library doesn't support multi-threading.

Cheers,
Nicholas Sherlock
Back to top
Chris Thompson
*nix forums addict


Joined: 09 Mar 2005
Posts: 57

PostPosted: Mon Feb 13, 2006 4:42 pm    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

In article <dsl62m$1hvr$1@gavrilo.mtu.ru>,
Maxim S. Shatskih <maxim@storagecraft.com> wrote:
Quote:
I'm not sure what 'reentrant' means here. AFAIK a program code segment
is usually reentrant in that it cannot normally be written to - so

I'm against the whole word of ''reentrant". It is, in fact, something from the
old time of MS-DOS add-ons which tried to do multitasking from this pathetic
OS.

MS-DOS? That's practically yesterday! We were talking about "reeentrant" and
"serially reusable" load modules back in OS/360, and it probably wasn't a
new term then.

--
Chris Thompson
Email: cet1 [at] cam.ac.uk
Back to top
David Schwartz
*nix forums Guru


Joined: 26 Feb 2005
Posts: 914

PostPosted: Mon Feb 13, 2006 10:04 am    Post subject: Re: Are Device Drivers Reentrant -- or Daemons? Reply with quote

"Alexei A. Frounze" <alexfru@chat.ru> wrote in message
news:45avjbF5pnlhU1@individual.net...

Quote:
For this reason (together with the fact that Unix doesn't support
threading at all), most Windows programs remain single-threaded;
programmers acquired the impression that multi-threading under Windows
was such a black art it wasn't worth the effort.

I'm not sure about that. To me it seems that some (or many?) people either
don't think about multithreading and continue to write code in the style
of 70s or have hard time understanding the entire concept and its
implications w/o connection to a particular OS.

A lot of Windows software sucks because programmers are unwilling to
learn how to correctly program to the modern WIN32 API. The biggest problem
is people who do things the UNIX way with the minimal changes needed to get
it to seem to work on Windows. The second-biggest problem is people who
still do horrible things you had to do back on Windows 3.1 thinking that you
still have to.

Today, the WIN32 API is suprisingly clean and surprisingly friends to
threading. A lot of things you have to go out of your way to get even close
to right on pthreads are trivial to do on Windows. (Not that it doesn't have
its own problems, of course.)

Perhaps as more programmers start to write multi-threaded programs on
UNIXes (since it is now very stable on most UNIXes people still care about),
WIN32 will benefit. If nothing else, multi-core CPUs should force people to
multi-thread because you have to if you want to get what the hardware is
capable of.

DS
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 4 [50 Posts] Goto page:  1, 2, 3, 4 Next
View previous topic :: View next topic
The time now is Sat Nov 22, 2008 12:30 pm | All times are GMT
navigation Forum index » Programming » Unix internals
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Flash device can't find in kernel and redboot Kevin embedded 1 Thu Jul 20, 2006 10:04 am
No new posts hostap drivers as Access Point Captain Dondo networking 0 Thu Jul 20, 2006 4:11 am
No new posts Question about PCI IDs and Drivers dutche Debian 8 Wed Jul 19, 2006 6:00 pm
No new posts raw device and solaris 10 osamaism@gmail.com Server 1 Wed Jul 19, 2006 9:11 am
No new posts raw device and solaris 10 osamaism@gmail.com Server 0 Wed Jul 19, 2006 9:11 am

Share Prices | Xecuter 3 Mod Chip | Free Ringtones | Secured Loans | Charity
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.3658s ][ Queries: 16 (0.2290s) ][ GZIP on - Debug on ]