Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer Help > Re: XNU sys_for...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 6 Topic 3729 of 3882
Post > Topic >>

Re: XNU sys_fork syscall (0x02). Differences between linux and XNU

by Ben Artin <macdev@[EMAIL PROTECTED] > May 1, 2008 at 11:55 AM

In article
<6ca4e552-9eda-4645-bf5f-483700048228@[EMAIL PROTECTED]
>,
 Robert Spykerman <robert.spykerman@[EMAIL PROTECTED]
> wrote:

> On May 1, 2:11 am, Ben Artin <mac...@[EMAIL PROTECTED]
> wrote: ...
> > That is particularly true on Mac OS X, where syscalls are not the
primitive 
> > way for userland code to communicate with the kernel -- Mach IPC is,
and 
> > syscalls are layered on top of Mach IPC. So, by using syscalls you are

> > *already* one layer above the kernel. If you want to be as close to
the 
> > kernel as possible, then you need to use Mach APIs directly; they tend
to 
> > be painfully complicated to call if you've never seen them before. If
you 
> > want to avoid the pain, you might as well use fork() in the C library,

> > which I believe will not have weird calling conventions.
> 
> Heh, Mach IPC eh?
> 
> Now you've got me REALLY interested. I live for pain by the way lol,
gonna 
> check this mach API out just for the heck of it.
> 
> So I imagine this mach IPC API is glue that allows stuff outside the
kernel 
> proper like device drivers and like to talk to the kernel and with each 
> other, I would imagine? Damn, there's a lot I still need to learn.

Basically, one of the fundamental concepts in the Mach kernel is that of a
Mach 
****t, which represents an access-controlled communication channel. It can
be 
used for two processes to talk to each other, two threads to talk to each
other, 
userland-to-kernel communication, driver-to-kernel communication, etc.

Essentially every kernel API (thread management, process management, VM,
file 
systems, networking, etc) is implemented as Mach messages to kernel's Mach

****ts. You can see more about this in kernel sources

> I'll go google some mach IPC stuff but if you've got some really good
primer 
> links, I'd be very grateful if you could share them with me :) Thanks
again.

Check out 
<http://developer.apple.com/do***entation/Darwin/Conceptual/KernelProgramming/>

and the kernel sources. In particular, the folder at 
<http://www.opensource.apple.com/darwinsource/10.5.2/xnu-1228.3.13/osfmk/mach/>

contains a bunch of .defs files which contain the IPC specifications for
kernel 
APIs.


For example, thread_act.defs contains the following:

/*
 * Assign thread to processor set.
 */
routine  thread_assign(
      thread      : thread_act_t;
      new_set     : processor_set_t);

as part of the API for controlling thread processor affinity. The file 
/usr/include/mach/thread_act.h is generated from that during the kernel 
compilation process, and the above declaration turns into:

extern
kern_return_t thread_assign
(
   thread_act_t thread,
   processor_set_t new_set
);

hth

Ben

-- 
If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>
 




 6 Posts in Topic:
XNU sys_fork syscall (0x02). Differences between linux and XNU
Robert Spykerman <robe  2008-04-29 19:01:42 
Re: XNU sys_fork syscall (0x02). Differences between linux and X
Ben Artin <macdev@[EMA  2008-04-30 02:58:53 
Re: XNU sys_fork syscall (0x02). Differences between linux and X
Robert Spykerman <robe  2008-04-30 04:48:38 
Re: XNU sys_fork syscall (0x02). Differences between linux and X
Ben Artin <macdev@[EMA  2008-04-30 12:11:24 
Re: XNU sys_fork syscall (0x02). Differences between linux and X
Robert Spykerman <robe  2008-04-30 17:16:19 
Re: XNU sys_fork syscall (0x02). Differences between linux and X
Ben Artin <macdev@[EMA  2008-05-01 11:55:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 10:44:59 CST 2008.