Newsgroups: comp.sys.transputer
From: Nicolas Iselin <iselin@iam.unibe.ch>
Subject: Re: How to cleanup the timer queues (kill process) on T80x
Organization: University of Berne
Date: Thu, 17 Jul 1997 16:18:06 +0200
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <33CE299E.32DE@iam.unibe.ch>

mueller@NoSpam130.83.24.72 wrote:
> 
> Hello
> 
> I wrote a assembler function to free all resources of a (crashed) program.
> 
> Channels to other modules are known by the OS and disconnected. Memory
> blocks and hardware resources too. Running low and high priority procs are
> removed from the transputers Qs if their workspace is located in a memory
> block witch owner is the program. This is done by a high priority process
> (not interuptable).
> 
> The problem is: how to clean up the timer Qs. I can use the same method as
> for the scheduler Qs. Most times this works fine. But I found no way to
> update the TimerNextRegs if necessary and I do not know when the transputer
> moves a process from the timer Q to the scheduler Q.

I did such tricks quite a long time ago: I wrote a program that could
intercept every low priority context switch and thus measure each
timeslice
(The overhead was awful, but it worked realiably). The main trick was
to move a 'spy' or 'helper' process into the queue. This enabled me to 
use as much as possible the 'standard' instructions which do care
for the necessary synchronisation in case of such subtle ties...

I would proceed as follows:

1. Is the timer queue empty ? -> We are done.
2. Do you have to remove the FIRST process in the timer queue ?
   if yes, 2 possibilities:
     . you simply wait until this process has become ready
       and remove it then from the ready queue. -> You are done
     . if this would take too long, insert your own process
       into the timer queue using the 'tin' instruction,
       remove the user process (which is not the first any more
       now) and wait until your own process is done.
       -> You are done.

I hope I did not miss something. If you still have no success, 
I can go and dig into my source code, because I had a
working algorithm in OCCAM cleaning up the timer queue.

Kind Regards, N. Iselin, iselin@iam.unibe.ch

