Page 1 of 1
how do shells relate to kernels?
Posted: Sun Jun 03, 2007 1:16 pm
by com1
does the shell of an OS have to be written in the kernel? if not, how does the shell communicate with the kernel in a microkernel environment?
thanks in advance,
Re: how do shells relate to kernels?
Posted: Sun Jun 03, 2007 1:30 pm
by Candy
com1 wrote:does the shell of an OS have to be written in the kernel? if not, how does the shell communicate with the kernel in a microkernel environment?
thanks in advance,
A shell is just an ordinary program with ordinary functions and so on. Make a shell in Minix to find out for yourself.
Re: how do shells relate to kernels?
Posted: Sun Jun 03, 2007 1:35 pm
by Brendan
Hi,
com1 wrote:does the shell of an OS have to be written in the kernel?
No, and I can't think of any (non-hobby) OS where the shell actually is implemented in the kernel (MS-DOS used "command.com", Windows uses a DOS emulator running "command.com", Linux/UNIX uses Bash or Ash or C-shell or Z-shell or something else, etc).
com1 wrote:if not, how does the shell communicate with the kernel in a microkernel environment?
In a micro-kernel environment, the shell would communicate with something that controls the user interface (e.g. a process responsible for virtual terminals), which (eventually) talks to device drivers.
AFAIK this is the same in UNIX - the shell uses it's stderr, stdout and stdin, which are typically connected to it's parent process (e.g. "term").
The kernel is responsible for the communication between these processes, and in a monolithic system it'd be responsible for the device drivers too (video, keyboard, mouse, etc), but apart from that the kernel has nothing to do with the shell - the shell is just another process as far as the kernel is concerned.
Cheers,
Brendan
Re: how do shells relate to kernels?
Posted: Sun Jun 03, 2007 5:18 pm
by Colonel Kernel
Brendan wrote:Windows uses a DOS emulator running "command.com"
For the sake of historical accuracy, I'd like to add that this was only true of Windows 9x/ME and earlier. NT/2k/XP use CMD.EXE, which looks and acts like DOS, but is not a DOS emulator (NTVDM.EXE is the dos emulator, and it can run command.com if you're feeling nostalgic). I think Vista has a new shell ("Powershell", formerly known as "Monad") but I haven't even sneezed in the general direction of Vista yet, so I don't know if this new shell is the default or not.
Some more examples of shells that are not in the kernel -- Explorer.exe on Windows, Finder on the Mac (shells can be graphical too).
Posted: Sun Jun 03, 2007 11:27 pm
by earlz
hmmm...anyone know of a portable shell? like portable to different OS's?
Posted: Mon Jun 04, 2007 1:19 am
by mathematician
hckr83 wrote:hmmm...anyone know of a portable shell? like portable to different OS's?
As it has been said, the shell is just another application, and, like all applications, it makes calls to the underlying operating system. You could have a shell which was portable at source code level, provided it didn't contain assembly language, but you would need a compiler which could compile it for the intended OS. If that OS was new, as in, "you've just written it," there is unlikely to be a compiler around to do the job. The only thing which makes the shell different from any other application is that it gets itself loaded automatically immediately after the OS has finished initialising.
By the way, a shell doesn't have to be a command line program. The word "shell" arises from the idea of its being something which wraps itself around the kernel, with the kernel on the inside and you on the outside. Windows primary shell is its GUI (which doesn't nowadays run on top of the command line interface).
Anyway, I imagine that a command line would be the easiest part of the operating system to write. After all, by then you have got a file system, memory manager, i/o to the console....... in fact everything an applications programmer takes for granted. (But unlike most applications programmers, you can go back and implement some more kernel functionality if you need it.)
Posted: Mon Jun 04, 2007 3:47 am
by jnc100
hckr83 wrote:hmmm...anyone know of a portable shell? like portable to different OS's?
Try
http://en.wikipedia.org/wiki/Category:Unix_shells. Most just require a standard C library, but can use others e.g. readline etc. From the looks of the articles, dash seems to be one of the simplest.
Regards,
John.
Posted: Mon Jun 04, 2007 11:30 am
by Candy
jnc100 wrote:hckr83 wrote:hmmm...anyone know of a portable shell? like portable to different OS's?
Try
http://en.wikipedia.org/wiki/Category:Unix_shells. Most just require a standard C library, but can use others e.g. readline etc. From the looks of the articles, dash seems to be one of the simplest.
www.sf.net/projects/ncsh -> intended to be portable. It's less than tested, though. It's derived from another project I started (but that was part of a school project),
www.sf.net/projects/cdsh. The last one is a bit more tested but uses readline.