System calls

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
FlashBurn

System calls

Post 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).
Whatever5k

Re:System calls

Post 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 ;)
FlashBurn

Re:System calls

Post 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!
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:System calls

Post 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 ... )
FlashBurn

Re:System calls

Post 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?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:System calls

Post 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.
FlashBurn

Re:System calls

Post 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?)
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:System calls

Post 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 :)
Post Reply