Page 1 of 1
System calls
Posted: Fri Apr 11, 2003 12:33 pm
by FlashBurn
I need some ideas how I could do things like read a file from the floppy disk for example. I will send a message and then I will wait till I get an answer. But what is when I get an answer but this is not from the floppy function? I mean how could I do this? I think I?ve heard of somehting, but I?m not sure if they are called spinloops? My problem is that I can?t write it as a interrupt procedure, because then the system wont be interrupted by the irq0 when it is time (because interrupts are of in an interrupt procedure).
Re:System calls
Posted: Fri Apr 11, 2003 12:39 pm
by Whatever5k
First of all, we need to know what type of kernel you are developing: monolithic or microkernel. As it seems, you are planning to write a microkernel, so that's how you would basically do it:
Every task (process manager, console manager, file system, etc.) gets called at startup, they all look quite similar, s.th. like this:
Code: Select all
void driver(void)
{
do_startup_things();
while(1) {
receive(&message);
switch(message.type) {
case READ: do_read;break;
case WRITE: do_write;break;
case EXIT: do_exit; break;
default: send(message.sender, TYPE_UNKNOWN);
}
}
So the drivers are just looping forever, and they have to be scheduled of course.
I don't know if that satisfises your question

Re:System calls
Posted: Sat Apr 12, 2003 5:51 am
by FlashBurn
Thanks for this example but I have another problem. Imagine that you have a gui app and a gui is a loop where you get a message and then do something with it or not. Now I want to load a file and send a message. Then I?m waiting for the reply. But in this waiting time also other messages will send to my app (e.g. resize of the window). So I need a way to call an interrupt but so that also the irq0 can be executed if the pit fired it!
Re:System calls
Posted: Sat Apr 12, 2003 9:34 am
by Pype.Clicker
note: using an software interrupt like INT 0x80 in your code don't block hardware interrupts! hardware interrupts are only blocked when IF=0 (and IF is cleared automatically when a HARDWARE interrupt is fired, but not in the case of a software interrupt ... )
Re:System calls
Posted: Sat Apr 12, 2003 12:31 pm
by FlashBurn
The first good message on this day

OK, but one more question, but it this has nothing to do with system calls. What size should have a message buffer for a task/thread?
Re:System calls
Posted: Sun Apr 13, 2003 7:03 am
by Pype.Clicker
neither too small nor too large ...
Personnally, i choose to have small message that can carry a 32-bits message identifier and 2*32 bits message data "in band" (out-of-band data can be stored in shared memory area whose localisation can be carried in-band).
I also choose not to give a fix-sized queue to each thread but rather to have a "pool" of messages and each message delivery request allocates a message from the pool and enqueue it to the target thread.
Re:System calls
Posted: Tue Apr 15, 2003 2:44 am
by FlashBurn
Back to the system calls. When the IF flag isn?t set also means that more than one program could access the interrupt! And I need a method that some special functions are only accessable by one task. For this I thought I could use messages, but there I get into a new problem

(that I need a answer message for which the program is waiting for, but what is when another message was sent to my program?)
Re:System calls
Posted: Tue Apr 15, 2003 2:49 pm
by Pype.Clicker
i don't really see what you mean with "IF not set -> more than one program can use the interrupt" ...
But however, if you want to give ONE single program the access to an interface, you can
- store the PID of that program with the interface and check the pid before the real interface is called. Trepassers will get errors on sight.
- give the program a LDT and put a CALL GATE for the service in its LDT, so that any other program can't even see the interface
