Hi. I'll 1st explain what I want to do. I have self propagating sequence of time intervals that are received in a MsgPort through PA_SoftInt or 3 set in the MsgPorts message arrival settings (mp_Flags). When a message is received I want to be able to change a forward linked list of structures wich have directory locks, wich are used by a process that records stuff to the HD according to received messages. There's no problem with race conditions, because the locks are changed/freed by the HD recorder process itself (a special message sent to it specifies what to change). However I'm having a problem sending the messages to it because I can't use any system memory allocation functions from an interrupt, hardware or software. I can however, according to the RKM Libs, use PutMsg() and Signal().
The solution I've invented is like this (I think it's pretty cool:)) Use a Semaphore to protect a BOOL variable or whatever piece of data that will serve as an arbitration. The Semaphore will be held constantly by another very small process that allocates memory and that's waiting for a signal to do it. The interrupt processing code will signal it to do it. Up to this point nothing will happend cause interrupts, even software ones, allways have an higher priority than tasks. Then the interrupt processing code will try to Obtain the said Semaphore exclusively, wich will of course make the memory allocating function work. After it's allocated the Memory to a shared memory address it relinquishes the Semaphore and the interrupt processing code can then use the allocated memory to send a message to the HD recorder process, wich frees the memory after processig the message.
I have 3 questions:
1- When the interrupt code loses the CPU when it ObtainSemaphore()s the system will be multitasking or only the small memory allocating process will execute ?
2- The RKM Libs has a list of functions that you can use from an interrupt and ObtainSemaphore is not one of them. This would make my solution not work, however the Semaphore system is documented to use signals and Signal() is a function you can use. I suppose the Semaphore lists could be inconsistent, but I wouldn't add the said semaphore to the system Semaphore list.
3- This is difficult, interesting, challenging and frustrating:lol: Is there a better way to achieve what I want to do ? Suggestions wanted/accepted.