Pipelining system calls?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Pipelining system calls?

Post by earlz »

Ok, so I was thinking about how context switching is probably the most expensive thign that is commonly done...(aside from task switching)

so, I was thinking...
what if each time a system call was done by a process, if it was added to a stack/list.... then, a process switch is done, and if another system call is doen, then add it to the list and switch processes, and when the current process is waiting on a system call, just do all the system calls in the stack, therefore making it cause only one context switch and such for that...

anyone kind of understand what I mean?
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

I get the idea, i think but who maintains the stack/list. i mean how can process 1 or process 2 add to a shared stack/list. Via a system call ? that would require a context switch anyways rendering the idea useless. how ever you could pipe systemcalls in a single process/thread. If a process would need to do more then one systemcall though i can't think of a situation yet.
Author of COBOS
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

But when a process issues a system call it is then destined to wait until that syscall has finished (it can't do anything else until!) so in effect anything that 'queues' or 'delays' syscalls is going to affect latency adversely.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

JamesM wrote:But when a process issues a system call it is then destined to wait until that syscall has finished (it can't do anything else until!) so in effect anything that 'queues' or 'delays' syscalls is going to affect latency adversely.
consider the following:

i want to map virtual memory segments say for instance 2 MiB to several locations in memory. (is the case with PlayStation memory shadowed at other addresses)

Code: Select all

char buffer[2*1024*1024];

vmap_user(0x00000000, buffer, sizeof(buffer));
vmap_user(0x80000000, buffer, sizeof(buffer));
vmap_user(0xA0000000, buffer, sizeof(buffer));
each of the vmap_user calls would do a context switch. If you could queue these calls as proposed, the same actions could be done with one context switch. Saving two switches and a lot of cpu cycles.
Author of COBOS
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Point taken, but most syscalls return a value or error code, making them synchronous. If you can find a way to avoid this, I'd be interested to know :)
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

In micro kernel the L4 set the standard going from asynchronous to synchronous which btw gave an enormous speed increase. So i am very reluctant to make asynchronous again. But for monolithic kernels it might work.
Author of COBOS
Avarok
Member
Member
Posts: 102
Joined: Thu Aug 30, 2007 9:09 pm

Post by Avarok »

Simple.

Instead of passing single parameters and returning instantly, instead pass a stack, and loop until it's empty. (pass an array on the stack and loop through it?)

You can try using RBP-RSP as an indicator, or JECXZ or whatever suits ya.

System calls are expensive enough to write everything as a loop over arguments if one in 10 calls you pass 2 sets of arguments.

Or so.

:twisted:
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies.
- C. A. R. Hoare
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

How does that solve the synchronous problem?
Post Reply