l4-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: deferred cancellation of ipc


From: Marcus Brinkmann
Subject: Re: deferred cancellation of ipc
Date: Tue, 14 Oct 2003 20:01:36 +0200
User-agent: Mutt/1.5.4i

Revised version with memory barriers.

I dropped l4ka because I feel that this has less and less to do specifically
with L4.

On Tue, Oct 14, 2003 at 04:25:04PM +0200, Marcus Brinkmann wrote:
> The ipc thread does something like this:
> 
> thread_var_in_ipc = 1;
  MEMORY BARRIER
> if (thread_var_ipc_cancel)
>   {
>     thread_var_in_ipc = 0;
      MEMORY BARRIER So in_ipc changes before ipc_cancel.
>     thread_var_ipc_cancel = 0;
      MEMORY BARRIER
>     return ECANCEL;  /* Or fake canceled Ipc() by setting ErrorCode
>                         and msg_tag.  */
>   }
> l4_ipc ();
> thread_var_in_ipc = 0;
  MEMORY BARRIER

Is that too heavy?
 
> The cancelling thread does something like this:
> 
> other_thread_status = stop_other_thread ();
  MEMORY BARRIER
> if (!other_thread_var_in_ipc)
>   other_thread_var_ipc_cancel = 1;
> else
>   {
>     if (is_currently_doing_ipc (other_thread_status))
>       ipc_cancel_other_thread ();
>     else
>       {
>         unsigned int tries = 0;
>         /* The other thread declared it is going to do an Ipc(), but is
>            not in it right now.  Give it a chance to make progress.  */
>         other_thread_var_ipc_cancel = 1;
          MEMORY BARRIER
> 
>         do
>           {
>             start_other_thread ();
>             if (tries <= 2)
>               {
>                 tries++;
>                 l4_yield (other_thread);
>               }
>              else
>               {
>                 /* We are not making any progress.  This might be because we
>                    are running on a different processor, and on this
>                    processor we are the only highest priority thread
>                    that is runnable, so we are spinning.  */
>                 /* 2^14 * 625 is the L4 default time slice length (10ms).  */
>                 l4_sleep (l4_time_period ((1 << 14) * 625) / 2);
>               }
>             other_thread_status = stop_other_thread ();
              MEMORY BARRIER
>           }
>         while (other_thread_var_ipc_cancel && other_thread_var_in_ipc &&
>                !is_currently_doing_ipc (other_thread_status);
>         if (other_thread_var_ipc_cancel && other_thread_var_in_ipc)
>           {
>             /* This means it is now in the IPC system call.  */
>             ipc_cancel_other_thread ();
>             other_thread_var_ipc_cancel = 0;
              MEMORY BARRIER
>           }
>         start_other_thread ();
>       }
>   }

-- 
`Rhubarb is no Egyptian god.' GNU      http://www.gnu.org    address@hidden
Marcus Brinkmann              The Hurd http://www.gnu.org/software/hurd/
address@hidden
http://www.marcus-brinkmann.de/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]