Re: Embedded linux: With or without MMU
- From: David Brown <david@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 11 Feb 2008 11:23:28 +0100
Michael Schnell wrote:
A good indication of whether or not a given Linux application will run under ucLinux is if it has a mingw windows port. Windows does not implement a "fork", ...
IMHO, "normal" applications don't spawn other independent applications. So there is no need for fork anyway.
Moreover the "standard" purpose of fork() is not to let the running application run twice, but to spawn a different executable file. And this is done with vfork() (nearly) exactly as with fork(). AFAI remember, I read, that in full Linux you can do vfork() as well (though it's not recommended) and in µCLinux you can only do vfork. It looks like in most cases the only porting effort is adding the "v" :).
There are three common uses that I can think of for (v)fork from "normal" applications. One is in forking servers, another other is for executing external subtasks, and the third is for splitting a task into parallel executed parts.
In the first case, things like webservers will often fork new processes to handle incoming connections. In this situation, it must be a real fork, since the new process keeps the same code and inherits things like file handles from the parent. This is a traditional unix server arrangement, and does not work well under ucLinux or windows ("fork" in *nix is extremely efficient using COW, but very slow if you don't have an MMU and must copy everything, or if the OS simply doesn't support the concept). Such servers need to be heavily modified to work without fork - they need to either use select() and other such asynchronous techniques, or they must use threads instead of processes. (Modern apache, for example, uses a mixture of forks and threads.)
For applications that fork off external subtasks, you normally see a fork/exec pair, often connected by a pipe to the parent. This sort of structure is normally fairly easily modified to a vfork.
For applications that use fork to parallise (is that a word?) their execution (keeping the same binary, but with different processes executing different parts of the code), it is probably better to re-write using threads. Traditionally, *nix was bad at thread handling - there was no standardisation, and it was very unclear how threads relate to processes for scheduling). Since fork was so cheap on *nix, there was no real need for threads - unlike on windows, where fork is expensive so threads were needed. But modern linux and ucLinux handle threads well, making it a good choice in many situations.
.
- Follow-Ups:
- Re: Embedded linux: With or without MMU
- From: Michael Schnell
- Re: Embedded linux: With or without MMU
- References:
- Embedded linux: With or without MMU
- From: MMJ
- Re: Embedded linux: With or without MMU
- From: Michael Schnell
- Re: Embedded linux: With or without MMU
- From: MMJ
- Re: Embedded linux: With or without MMU
- From: Michael Schnell
- Re: Embedded linux: With or without MMU
- From: Morten M. Jørgensen
- Re: Embedded linux: With or without MMU
- From: David Brown
- Re: Embedded linux: With or without MMU
- From: Michael Schnell
- Embedded linux: With or without MMU
- Prev by Date: Re: Embedded linux: With or without MMU
- Next by Date: 請問
- Previous by thread: Re: Embedded linux: With or without MMU
- Next by thread: Re: Embedded linux: With or without MMU
- Index(es):
Relevant Pages
|
|