OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 5:33 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Pipelining system calls?
PostPosted: Thu Oct 18, 2007 11:01 pm 
Offline
Member
Member

Joined: Thu Jul 07, 2005 11:00 pm
Posts: 1546
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?

_________________
My new NEW blag


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 2:13 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 27, 2007 3:21 pm
Posts: 553
Location: Best, Netherlands
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 3:57 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
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.

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 4:44 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 27, 2007 3:21 pm
Posts: 553
Location: Best, Netherlands
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:
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 5:04 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
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 :)

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 5:09 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 27, 2007 3:21 pm
Posts: 553
Location: Best, Netherlands
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 8:20 am 
Offline
Member
Member

Joined: Thu Aug 30, 2007 9:09 pm
Posts: 102
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 8:42 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
How does that solve the synchronous problem?

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 33 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group