Unix Programming - Standard C library functions in freestanding systems

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > September 2007 > Standard C library functions in freestanding systems





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Standard C library functions in freestanding systems
J de Boyne Pollard

2007-09-19, 1:27 pm

M> The library functions which are included to allow process
M> launch, forking, and termination, imply that it is both
M> possible and desirable for a process to fork itself. This
M> is a fundamental part of the Unix thought process, but is
M> not essential for a working OS.

RP> How do you intend for users to run programs? You'd
RP> still need to allow process launch and termination, even
RP> if you eliminated forking. [...]

Note that what Matt wrote was confused. Forking _is_ process
launching. It is how one creates a new process. The phrase "launch,
forking, and termination" is like the phrase "glucose and sugar" used
in Mars Bar advertisements in some countries during the 20th century,
which at least one chemist used to translate to "sugar and more
sugar". The correct third action, to group with forking and
termination, is program image overlay -- i.e. execve().

Martin Golding

2007-09-19, 1:27 pm

On Wed, 19 Sep 2007 05:53:26 -0700, J de Boyne Pollard wrote:

> M> The library functions which are included to allow process M> launch,
> forking, and termination, imply that it is both M> possible and
> desirable for a process to fork itself. This M> is a fundamental part of
> the Unix thought process, but is M> not essential for a working OS.
>
> RP> How do you intend for users to run programs? You'd RP> still need
> to allow process launch and termination, even RP> if you eliminated
> forking. [...]
>
> Note that what Matt wrote was confused. Forking _is_ process launching.
> It is how one creates a new process.


Fork() is, I believe, a unix invention. I have worked on OSs which
did not require fork(), some of which OSs did not implement fork().
For some process and executable implementations it is trivial to
create a process starting at a specified instruction or with a
specified executable, and non-trivial to impossible to create a
process that shares or copies the state of a running process.

<OT>
I have also worked on an OS which, on boot, fully populated its
(fixed size) task table with running processes, most of which
rapidly entered some wait-for-event state. "Launching" a process
required acquiring one of the active-but-unallocated processes
and modifying its top-of-stack to goto the desired instruction.
I strongly doubt that there has ever been a C compiler for such
an OS.
</OT>

Martin
--
Martin Golding DoD #0236 | fogobum@comcast.net
Always code as if the person who ends up maintaining your code will be a
violent psychopath who knows where you live.
Rainer Weikusat

2007-09-19, 1:27 pm

Martin Golding <fogobum@comcast.net> writes:
> On Wed, 19 Sep 2007 05:53:26 -0700, J de Boyne Pollard wrote:
>
> Fork() is, I believe, a unix invention.


That doesn't make it any more sensible to include both 'process launching'
and 'forking' in a list of primitives.
Rod Pemberton

2007-09-19, 7:20 pm


"J de Boyne Pollard" <j.deboynepollard@tesco.net> wrote in message
news:1190206406.960518.260140@r29g2000hsg.googlegroups.com...
> M> The library functions which are included to allow process
> M> launch, forking, and termination, imply that it is both
> M> possible and desirable for a process to fork itself. This
> M> is a fundamental part of the Unix thought process, but is
> M> not essential for a working OS.
>
> RP> How do you intend for users to run programs? You'd
> RP> still need to allow process launch and termination, even
> RP> if you eliminated forking. [...]
>
> Note that what Matt wrote was confused. Forking _is_ process
> launching. It is how one creates a new process.


I understood his mention of forking to be one user process creating another
user process. Whereas, I understood process launch and termination as the
OS creating and destroying a user process. Depending on the OS
implementation these may be indentical or different or non-existent in part
or full.


Rod Pemberton

Army1987

2007-09-19, 7:20 pm

[removed f'up to clc, I can't see what this have to do with C]
On Wed, 19 Sep 2007 05:53:26 -0700, J de Boyne Pollard wrote:
> Note that what Matt wrote was confused. Forking _is_ process
> launching. It is how one creates a new process. The phrase "launch,
> forking, and termination" is like the phrase "glucose and sugar" used
> in Mars Bar advertisements in some countries during the 20th century,
> which at least one chemist used to translate to "sugar and more
> sugar". The correct third action, to group with forking and
> termination, is program image overlay -- i.e. execve().

On some OSes, you can create a new process which is not a copy of
an existing one, much like sucrose is a sugar which is not
glucose.
--
Army1987 (Replace "NOSPAM" with "email")
If you're sending e-mail from a Windows machine, turn off Microsoft's
stupid “Smart Quotes” feature. This is so you'll avoid sprinkling garbage
characters through your mail. -- Eric S. Raymond and Rick Moen

CBFalconer

2007-09-20, 1:27 am

Martin Golding wrote:
> On Wed, 19 Sep 2007 05:53:26 -0700, J de Boyne Pollard wrote:
>
>
> Fork() is, I believe, a unix invention. I have worked on OSs which
> did not require fork(), some of which OSs did not implement fork().
> For some process and executable implementations it is trivial to
> create a process starting at a specified instruction or with a
> specified executable, and non-trivial to impossible to create a
> process that shares or copies the state of a running process.


The above messing up of the previous quotations is a sufficient
reason to avoid non-standard quotation markings. M. Pollard should
take note.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>



--
Posted via a free Usenet account from http://www.teranews.com

Chris Torek

2007-09-20, 1:27 am

[comp.lang.c removed since it is irrelevant]

In article <pan.2007.09.19.16.26.38@comcast.net>
Martin Golding <fogobum@comcast.net> wrote:
>Fork() is, I believe, a unix invention.


Actually, it was taken from an even earlier system on the SDS Sigma.
See <http://cm.bell-labs.com/cm/cs/who/dmr/hist.html>.

Many OSes have a combined "fork and exec" primitive, often called
"spawn" (or some variant of that name). One big argument for this is
efficiency: a typical Unix-like process sequence is:

pid = fork();
if (pid == 0) {
... do some setup work ...
execve(path, argv, env);
_exit(CODE);
}

and depending on the "setup work" involved, a single call like:

pid = spawnve(path, argv, env, SETUP_WORK_FLAGS);

is obviously "more efficient": here, we need not duplicate the
entire original process just to throw it away and replace it with
the new image.

The problem is that the "setup work" can be, and -- at least
surprisingly often -- actually turns out to be, "arbitrarily
complicated". The OS that lacks fork() forces this work to be
encoded in an argument to spawnve(). This winds up being too
restrictive, and eventually, such systems often acquire a primitive
more or less equivalent to fork() after all. :-)

(An alternative solution is to provide actual code, rather than
just flags, to the spawn call. This method depends on a number of
other system features, such as security enforcement mechanisms and
perhaps relocatable code.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (4039.22'N, 11150.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Scott Lurndal

2007-09-21, 1:27 pm

Martin Golding <fogobum@comcast.net> writes:
>On Wed, 19 Sep 2007 05:53:26 -0700, J de Boyne Pollard wrote:
>
>
>Fork() is, I believe, a unix invention. I have worked on OSs which
>did not require fork(), some of which OSs did not implement fork().


Tell that to the Burroughs B-5500 engineers. The routine in the
Master Control Program (MCP) to create a new task/process was called
"motherforker". This predated unix.

scott
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com