how system calls work

  • Follow


hi folks,
how does system calls work,like how an application can invoke a system
call, Does it have to do through IPC or any other mechanism , how
exactly a system call is invoked by an application in linux.

cheers
sinbad

0
Reply sinbad.sinbad (155) 3/29/2007 5:11:53 AM

On 2007-03-29, sinbad wrote:
> hi folks,
> how does system calls work,like how an application can invoke a system
> call, Does it have to do through IPC or any other mechanism , how
> exactly a system call is invoked by an application in linux.

Look it up.

Do your own homework, boy.


-- 
"Ubuntu" - an African word meaning "Slackware is too hard for me".

0
Reply youmustbejoking (340) 3/29/2007 5:27:50 AM


On Mar 29, 10:27 am, Dan C <youmustbejok...@invalid.lan> wrote:
> On 2007-03-29, sinbad wrote:
> > hi folks,
> > howdoessystemcallswork,like how an application can invoke asystem
> > call,Doesit have to do through IPC or any other mechanism , how
> > exactly asystemcall is invoked by an application in linux.
>
> Look it up.
>
> Do your own homework, boy.
>
> --
> "Ubuntu" - an African word meaning "Slackware is too hard for me".

i checked it out in the groups , couldn't find a clue , can u give
some pointers , all the o.s literature explains only why the system
calls are used,
i couldn't find anyone explaining sequence of operations done during
the system call , Any pointers would be appreciated.

cheers
sinbad

0
Reply sinbad.sinbad (155) 3/29/2007 9:15:09 AM

sinbad wrote:
> hi folks,
> how does system calls work,like how an application can invoke a system
> call, Does it have to do through IPC or any other mechanism , how
> exactly a system call is invoked by an application in linux.
> 
> cheers
> sinbad
> 
It depends on the processor you are using. In most machines there is an
instruction that causes a hardware interrupt that switches the the memory
management to a different setup, saves the current context, and transfers to
a specified address in the new memory address space (in the kernel).
Usually, just before that instruction is issued, the arguments to the system
call are put in some of the registers so the kernel can find them.

Depending on the hardware, more or less of this may have to be done in
software. You might look at the source of one of the system calls; i.e.,
look at something like the source of read() in glibc-devel package.



-- 
  .~.  Jean-David Beyer          Registered Linux User 85642.
  /V\  PGP-Key: 9A2FC99A         Registered Machine   241939.
 /( )\ Shrewsbury, New Jersey    http://counter.li.org
 ^^-^^ 06:20:01 up 40 days, 17:46, 3 users, load average: 4.43, 4.25, 4.11
0
Reply jeandavid8 (968) 3/29/2007 11:23:03 AM

sinbad wrote:
> On Mar 29, 10:27 am, Dan C <youmustbejok...@invalid.lan> wrote:
>> On 2007-03-29, sinbad wrote:
>>> hi folks,
>>> howdoessystemcallswork,like how an application can invoke asystem
>>> call,Doesit have to do through IPC or any other mechanism , how
>>> exactly asystemcall is invoked by an application in linux.
>> Look it up.
>>
>> Do your own homework, boy.
>>
>> --
>> "Ubuntu" - an African word meaning "Slackware is too hard for me".
> 
> i checked it out in the groups , couldn't find a clue , can u give
> some pointers , all the o.s literature explains only why the system
> calls are used,
> i couldn't find anyone explaining sequence of operations done during
> the system call , Any pointers would be appreciated.
> 
> cheers
> sinbad
> 
You invoke them throuhh libraries..if by system call you mean to the 
operating system..

confusing as 'system()' in C means 'spawn a shell'

How the libraries do it is dependent on the hardware architecture.

It may be simply a subroutine call to a fixed location, or it may be 
some sort of privileged interrupt type affair.

0
Reply The 3/29/2007 1:15:08 PM

I demand that The Natural Philosopher may or may not have written...

[snip]
> You invoke them throuhh libraries..if by system call you mean to the 
> operating system..

> confusing as 'system()' in C means 'spawn a shell'
 
> How the libraries do it is dependent on the hardware architecture.
> 
> It may be simply a subroutine call to a fixed location, or it may be 
> some sort of privileged interrupt type affair.
> 

-- 
| Darren Salt    | linux or ds at              | nr. Ashington, | Toon
| RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
|   Kill all extremists!

Drive not ready, 0:1
0
Reply news64 (1253) 3/29/2007 4:14:11 PM

I demand that The Natural Philosopher may or may not have written...

[snip]
> You invoke them throuhh libraries..if by system call you mean to the 
> operating system..

> confusing as 'system()' in C means 'spawn a shell'

On Linux, at least. On some other OSes, it might be "call the kernel's
command line parser".

(Not that that's relevant here, but still...)

[snip]
-- 
| Darren Salt    | linux or ds at              | nr. Ashington, | Toon
| RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
|   Kill all extremists!

Drive not ready, 0:1
0
Reply news64 (1253) 3/29/2007 4:16:14 PM

sinbad wrote:
> hi folks,
> how does system calls work,like how an application can invoke a system
> call, Does it have to do through IPC or any other mechanism , how
> exactly a system call is invoked by an application in linux.
> 
> cheers
> sinbad


(Question posted from an Indian DSL line).

Homework / study assignment?

Get the book 'Understanding the Linux kernel', read
and understand it.

There is no simple response for such a question
without any background information.

-- 

Tauno Voipio
tauno voipio (at) iki fi
0
Reply tauno.voipio (652) 3/29/2007 5:20:06 PM

On Mar 29, 10:20 pm, Tauno Voipio <tauno.voi...@INVALIDiki.fi> wrote:
> sinbad wrote:
> > hi folks,
> > how does system calls work,like how an application can invoke a system
> > call, Does it have to do through IPC or any other mechanism , how
> > exactly a system call is invoked by an application in linux.
>
> > cheers
> > sinbad
>
> (Question posted from an Indian DSL line).
>
> Homework / study assignment?
>
> Get the book 'Understanding the Linux kernel', read
> and understand it.
>
> There is no simple response for such a question
> without any background information.
>
> --
>
> Tauno Voipio
> tauno voipio (at) iki fi

Hi folks, I did my homework and found very interesting article about
system calls . Check out the following link ...
http://www-128.ibm.com/developerworks/linux/library/l-system-calls/index.html

btw tauno , don't get mad , how could u find that i posted the 'Q'
from indian DSL line .... well i say it's not true ;) ...

Cheers
sinbad

"when you are chasing a dream , You will not be able to see the beauty
right infront of your eyes "

0
Reply sinbad.sinbad (155) 3/30/2007 5:11:34 AM

sinbad wrote:
> 
> Hi folks, I did my homework and found very interesting article about
> system calls . Check out the following link ...
> http://www-128.ibm.com/developerworks/linux/library/l-system-calls/index.html
> 
> btw tauno , don't get mad , how could u find that i posted the 'Q'
> from indian DSL line .... well i say it's not true ;) ...
> 
> Cheers
> sinbad

Are you saying that it's not correct?

-- 

Tauno Voipio
tauno voipio (at) iki fi
0
Reply tauno.voipio (652) 3/30/2007 6:23:03 PM

On Mar 30, 11:23 pm, Tauno Voipio <tauno.voi...@INVALIDiki.fi> wrote:
> sinbadwrote:
>
> > Hi folks, I did my homework and found very interesting article about
> > system calls . Check out the following link ...
> >http://www-128.ibm.com/developerworks/linux/library/l-system-calls/in...
>
> > btw tauno , don't get mad , how could u find that i posted the 'Q'
> > from indian DSL line .... well i say it's not true ;) ...
>
> > Cheers
> >sinbad
>
> Are you saying that it's not correct?
>
> --
>
> Tauno Voipio
> tauno voipio (at) iki fi

yeah , that' right , how could u find that ...

0
Reply sinbad.sinbad (155) 4/1/2007 3:02:49 AM

On Sat, 31 Mar 2007 20:02:49 -0700, sinbad wrote:

>> > btw tauno , don't get mad , how could u find that i posted the 'Q'
>> > from indian DSL line .... well i say it's not true ;) ...

>> Are you saying that it's not correct?
 
> yeah , that' right , how could u find that ...

By doing a search on the IP address you're posting from.  It's quite
trivial in fact.  Here's some more info:

Your IP address:  59.162.130.163 (Bombay, India)
Connecting to the Internet through:
Videsh Sanchar Nigam Ltd - India.

How's that?

-- 
"Ubuntu" -- an African word, meaning "Slackware is too hard for me".

0
Reply youmustbejoking2 (560) 4/1/2007 3:45:49 AM

sinbad wrote:
> 
.... snip ...
> 
> yeah , that' right , how could u find that ...

Who is 'u'?  Fix your broken shift key.

-- 
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

0
Reply cbfalconer (19183) 4/1/2007 6:27:38 AM

CBFalconer <cbfalconer@yahoo.com> writes:

> sinbad wrote:
>> 
> ... snip ...
>> 
>> yeah , that' right , how could u find that ...
>
> Who is 'u'?  Fix your broken shift key.

If you have nothing to add which is pertinent to the thread, why don't
you crawl back under the stone from which you appeared?
0
Reply hadronquark (20902) 4/1/2007 3:00:21 PM

CBFalconer wrote:
> sinbad wrote: ... snip ...
>> yeah , that' right , how could u find that ...
> 
> Who is 'u'?  Fix your broken shift key.
> 
    Reminds me of the time I went over to a co-workers house to fix his
Windoze box. His girl friend answered the door with about 4 sets of
inquisitive eyes peeking around from her well filled out Jeans and
announced that he was not home. I told her I would be back later to work
on his computer. She asked, "Who is you?"

How do you answer that?
0
Reply user7 (3884) 4/1/2007 3:21:36 PM

On 2007-04-01, Hadron <hadronquark@gmail.com> wrote:
> CBFalconer <cbfalconer@yahoo.com> writes:
>
>> sinbad wrote:
>>> 
>> ... snip ...
>>> 
>>> yeah , that' right , how could u find that ...
>>
>> Who is 'u'?  Fix your broken shift key.
>
> If you have nothing to add which is pertinent to the thread,
> why don't you crawl back under the stone from which you
> appeared?

I thought his posting was quite pertinent, thank you.

-- 
Grant Edwards                   grante             Yow!  Will it improve my
                                  at               CASH FLOW?
                               visi.com            
0
Reply grante (5411) 4/1/2007 3:45:31 PM

On 04/01/2007 08:30 PM, Hadron wrote:
> CBFalconer <cbfalconer@yahoo.com> writes:
> 
>> sinbad wrote:
>> ... snip ...
>>> yeah , that' right , how could u find that ...
>> Who is 'u'?  Fix your broken shift key.
> 
> If you have nothing to add which is pertinent to the thread, why don't
> you crawl back under the stone from which you appeared?

And what's the hell that good thing is you ever have added to any of the 
newsgroups where you usually lurk around?

*PLONK*

-- 
Dr Balwinder S "bsd" Dheeman          Registered Linux User: #229709
Anu'z Linux@HOME                      Machines: #168573, 170593, 259192
Chandigarh, UT, 160062, India         Gentoo, Fedora, Knoppix/FreeBSD/XP
Home: http://cto.homelinux.net/~bsd/  Visit: http://counter.li.org/
0
Reply bsd.sanspam (639) 4/1/2007 4:11:47 PM

"Balwinder S \"bsd\" Dheeman" <bsd.SANSPAM@cto.homelinux.net> writes:

> On 04/01/2007 08:30 PM, Hadron wrote:
>> CBFalconer <cbfalconer@yahoo.com> writes:
>>
>>> sinbad wrote:
>>> ... snip ...
>>>> yeah , that' right , how could u find that ...
>>> Who is 'u'?  Fix your broken shift key.
>>
>> If you have nothing to add which is pertinent to the thread, why don't
>> you crawl back under the stone from which you appeared?
>
> And what's the hell that good thing is you ever have added to any of
> the newsgroups where you usually lurk around?
>
> *PLONK*

Quite a lot actually. And calm down - you almost didn't make any
sense. If you think it's ok to chase people around all day pointing out
errors in peoples posting styles while not actually contributing to the
issue at hand then fair enough - I welcome your killfile with open
arms. Clearly another cbf in the making.
0
Reply hadronquark (20902) 4/1/2007 4:55:57 PM

On Apr 1, 9:55 pm, Hadron <hadronqu...@gmail.com> wrote:
> "Balwinder S \"bsd\" Dheeman" <bsd.SANS...@cto.homelinux.net> writes:
>
> > On 04/01/2007 08:30 PM, Hadron wrote:
> >> CBFalconer <cbfalco...@yahoo.com> writes:
>
> >>>sinbadwrote:
> >>> ... snip ...
> >>>> yeah , that' right , how could u find that ...
> >>> Who is 'u'?  Fix your broken shift key.
>
> >> If you have nothing to add which is pertinent to the thread, why don't
> >> you crawl back under the stone from which you appeared?
>
> > And what's the hell that good thing is you ever have added to any of
> > the newsgroups where you usually lurk around?
>
> > *PLONK*
>
> Quite a lot actually. And calm down - you almost didn't make any
> sense. If you think it's ok to chase people around all day pointing out
> errors in peoples posting styles while not actually contributing to the
> issue at hand then fair enough - I welcome your killfile with open
> arms. Clearly another cbf in the making.


why should we follow such a complex mechanism when a system call is
invoked, why can't it be a simple function call.why the processor
should know it is executing in kernel mode. Anyone pls shed some light
on it.

cheers
sinbad

0
Reply sinbad.sinbad (155) 4/2/2007 9:29:42 AM

sinbad wrote:

> why should we follow such a complex mechanism when a system call is
> invoked, why can't it be a simple function call.why the processor
> should know it is executing in kernel mode. Anyone pls shed some light
> on it.
> 
You really should read the textbook of the course you are taking.

At one level (the level the writer of the usual application programmer
writes at), all it is _is_ a simple function call.

At the next level down, that _simple function call_ causes a hardware
interrupt so that the hardware changes context, usually from the user level
to the kernel level where the OS works specifically so that the memory
management registers can be set up to give the kernel access to instructions
and address space invisible to ordinary application programs. If ordinary
application programs had access to these instructions and address space (as
they did have in the late 1950s and early 1960s), there could be no
isolation between the different applications and the between the
applications and the OS itself. Without that isolation, bugs in one program
could (and did) compromise other programs. This kind of thing was solved
around 1965 when MIT's CTSS operating system came out. A little later, IBM,
General Electric, and others came up with operating systems with similar
memory management arrangements, all of which permitted running time-sharing
operating systems with some degrees of success. AFAIK, by about 1970, almost
all computers were capable of multiprogramming. About the only exceptions
were the operating systems used on pesronal type computers using processors
such as the Intel 8086 that did not have adequate memory management
included, even on add-on chips. I think Intel did not get there until the 80386.

You really ought to read a textbook on operating system design, not one on
implementation, because you need to understand the forest of fundamental
problems operating systems try to solve before you confront the trees of
implementation for any particular operating system and hardware.

-- 
  .~.  Jean-David Beyer          Registered Linux User 85642.
  /V\  PGP-Key: 9A2FC99A         Registered Machine   241939.
 /( )\ Shrewsbury, New Jersey    http://counter.li.org
 ^^-^^ 07:15:01 up 44 days, 18:41, 3 users, load average: 4.97, 4.54, 4.23
0
Reply jeandavid8 (968) 4/2/2007 11:28:14 AM

sinbad wrote:
> On Apr 1, 9:55 pm, Hadron <hadronqu...@gmail.com> wrote:
>> "Balwinder S \"bsd\" Dheeman" <bsd.SANS...@cto.homelinux.net> writes:
>>
>>> On 04/01/2007 08:30 PM, Hadron wrote:
>>>> CBFalconer <cbfalco...@yahoo.com> writes:
>>>>> sinbadwrote:
>>>>> ... snip ...
>>>>>> yeah , that' right , how could u find that ...
>>>>> Who is 'u'?  Fix your broken shift key.
>>>> If you have nothing to add which is pertinent to the thread, why don't
>>>> you crawl back under the stone from which you appeared?
>>> And what's the hell that good thing is you ever have added to any of
>>> the newsgroups where you usually lurk around?
>>> *PLONK*
>> Quite a lot actually. And calm down - you almost didn't make any
>> sense. If you think it's ok to chase people around all day pointing out
>> errors in peoples posting styles while not actually contributing to the
>> issue at hand then fair enough - I welcome your killfile with open
>> arms. Clearly another cbf in the making.
> 
> 
> why should we follow such a complex mechanism when a system call is
> invoked, why can't it be a simple function call.why the processor
> should know it is executing in kernel mode. Anyone pls shed some light
> on it.
Jean-David Beyer gave you the complicated answer, the simpler precis of 
what he said is as follows.

A program, in order not to be able to crash the while operating system, 
is these days designed to run in a limited environment. In particular it 
cannot access memory other tan that which tyhe operating system allows 
it to,  nor can it have direct access to the hardware - screen, disk 
keyboards etc..

This is enforced by first of all denying access to all of this via 
hardware mechanisms, and then using the operating system to arbitrate 
access to these components.

This has long been a feature of mainframe ind minicomputers, but I think 
Jean is totally correct when he says that the 80386 was the first intel 
chip to implement it in hardware.

The reason being that some scabby little student can't then ompile up a 
program as a someone other than superuser, and totally compromise a 
machine to which hundreds of people are connected doing useful things. etc.

Any attempts to violate memory areas or access hardware will get either 
an out of bounds error or lack of privileges system call. Which 
generally results in a sharp program exit, or possibly an rude message.

Not a crashed computer.

As someone who has crashed a computer with 60 people working on it, I 
can assure you this is a Good Thing!


> 
> cheers
> sinbad
> 
0
Reply The 4/2/2007 11:45:22 AM

20 Replies
34 Views

(page loaded in 0.272 seconds)


Reply: