|
||
Title: Operating System Concepts queries -HELP Post by puzzlecracker on Nov 23rd, 2004, 3:10pm 1) what exactly happend in LINUX OS when script such bash or perl is execute? what are the steps of the compiler and OS? 2) when 'ls' is called, is fork()/exec() are invoked by the system??? |
||
Title: Re: Operating System Concepts queries -HELP Post by John_Gaughan on Nov 23rd, 2004, 8:53pm Is this homework? You know you can always check the source. Linux is great, the kernel is freely available in source code form. |
||
Title: Re: Operating System Concepts queries -HELP Post by puzzlecracker on Nov 23rd, 2004, 9:17pm No, these are interview questions |
||
Title: Re: Operating System Concepts queries -HELP Post by puzzlecracker on Nov 28th, 2004, 10:33pm If no one really knows these concepts and Linux OS, I will research it myself so that others along with me can get an understanding of these very important and fundamental ideas of CS. just for clarification: does fork()/exec() apply to 'ls' AS WELL AS "cd" command? I am curios about other system calls. and see wether there is a difference among them in terms of implementation. GOod Luck fellowsssssssss............ |
||
Title: Re: Operating System Concepts queries -HELP Post by Grimbal on Nov 29th, 2004, 2:08am For 2) I believe that when the shell interprets 'ls', ls being a program (/usr/bin/ls or so), the shell will fork() a new process and that new process will call exec() to load and execute the /usr/bin/ls program. |
||
Title: Re: Operating System Concepts queries -HELP Post by puzzlecracker on Nov 29th, 2004, 10:13am Hey linux gurus, I looked through the source but couldn't find the actual implementaion of netither ls and cd: http://lxr.linux.no/source/ if anyone is able, please inform me. thx |
||
Title: Re: Operating System Concepts queries -HELP Post by Aryabhatta on Nov 29th, 2004, 10:24am on 11/29/04 at 10:13:20, puzzlecracker wrote:
ls is _not_ a system call. It is an executable. cd is a shell shorthand for the system call chdir. ls is just like any other executable. My guess is you are actually looking for ways to read directories and list them, along with their permissions etc. read the man page about readdir, stat, etc. When you type in a executable name, the shell finds it (usually using the PATH variable) and then forks a new process. The child process then exec's the executable. fork/exec are functions in the stdlib which call the system calls fork and execve. Hope that helps. |
||
Title: Re: Operating System Concepts queries -HELP Post by puzzlecracker on Nov 29th, 2004, 12:26pm That explains: as for the system call? does it also fork and exec to a different process????? ::) |
||
Title: Re: Operating System Concepts queries -HELP Post by Aryabhatta on Nov 30th, 2004, 11:07am on 11/29/04 at 12:26:32, puzzlecracker wrote:
system calls are executed as part of the same process. For eg, fork is a system call, if we were executing them in a new process, how would we fork (to create the new process) to execute it? Anyway, normally a process is capable of running in 2 (mutually exclusive) modes. The usual user mode and the kernel mode which does the system call execution. Usually there is hardware support which allows the user to trap into (or jump into) the priviledged (kernel) mode (can read/write files etc). For instance in linux on intel x86 machine, system calls are executed by filling the proper registers (which system call and the arguments to the system call) and executing the machine instruction: int 0x80. This causes the the process to go into the kernel mode, where it can do its stuff and then the kernel then returns back to the user mode when the job is done. The user mode is not very priviledged and can mostly read/write memory which is available to it, and execute specific system calls. I would suggest you read a good book on Operating Systems. One such book is "Unix Operating System" by Maurice Bach. Hope that helps. |
||
Title: Re: Operating System Concepts queries -HELP Post by puzzlecracker on Nov 30th, 2004, 3:30pm GREAT, really GREAT help... so clear and elicit now.... Here is the master question though, how do I know, that is can at lest intuively reason, which command involves system call and which involves the processes creation? Is there a guidline that one should follow or simply know as is....................? Thanks again... |
||
Title: Re: Operating System Concepts queries -HELP Post by Aryabhatta on Nov 30th, 2004, 5:18pm on 11/30/04 at 15:30:56, puzzlecracker wrote:
What do you mean by 'command'? Are you talking about commands to the shell, say like bash? You might want to read what shell builtins are there and how they translate (if at all they translate) to system calls. Eg: cd translates directly to chdir, but 'if' or 'for' do not need system calls. Shell redirection (using > file) uses system calls open and dup/dup2. Running executables (like ls) will involve the system call exec and fork (in most cases). So if you do something like ls > file, the systems calls could be fork, exec, open and dup and close (and probably other system calls). It would help if you had a knowledge of what system calls are available. A way to judge what is happening is: what would _you_ have done to provide that feature in a shell which you would write (you would need to know what system calls are available for that though). If you just want to know if a new process has been created, you could just use 'ps' (from say a different shell) to look at the list of processes and try to figure out., but it is usually when an executable is executed by the shell (for instance when you type in ps, which is actually the executable /bin/ps or something similar), that a new process is created. To get started you could read some faqs available on the net. I think one was called unix.programmer.faq, sorry don't remember clearly. Or maybe you could read some book about systems programming... Hope that helps. |
||
Title: Re: Operating System Concepts queries -HELP Post by TenaliRaman on Dec 1st, 2004, 9:35pm check here for a "blunt" list of system calls, http://www.sju.edu/~jhodgson/systems/sys_call.html U can man them to find more abt them. |
||
Title: Re: Operating System Concepts queries -HELP Post by John_Gaughan on Dec 7th, 2004, 11:00am Try looking in the /bin directory. There you will find your utilities such as ls, rm, and cd. They are part of (I think) the GNU core utilities package. |
||
Title: Re: Operating System Concepts queries -HELP Post by igni_ferroque on Dec 7th, 2004, 8:27pm Quote:
The operating system recognizes the two-byte magic cookie '#!' (also called the she-bang!) and executes the program (interpreter) specified by the string following the she-bang. The path of the script file appears as the second argument passed to the interpreter (argv[1]), followed by any arguments passed to the script file. |
||
Powered by YaBB 1 Gold - SP 1.4! Forum software copyright © 2000-2004 Yet another Bulletin Board |