nanogui: Thread: how to SendMessage?


[<<] [<] Page 1 of 1 [>] [>>]
Subject: how to SendMessage?
From: ShenChong ####@####.####
Date: 19 Nov 1999 02:07:25 -0000
Message-Id: <3834AF54.16AAF958@term.star.com.cn>

I want to port Microwindows to our multi-thread use.
In "MicroSoft" Win32 API, SendMessage to other thread will suspend
self.
If there are two threads: A and B, A send message to B(call SendMessage)

and at the same time B call SendMessage to send message to A. A and B
both suspend themselves.There is a deadlock.
How "MicroSoft" solves it? Does anybody know?

Subject: RE: how to SendMessage?
From: Greg Haerr ####@####.####
Date: 19 Nov 1999 02:54:13 -0000
Message-Id: <01BF31FE.F2F7BF00.greg@censoft.com>

On Thursday, November 18, 1999 7:01 PM, ShenChong ####@####.#### wrote:
: I want to port Microwindows to our multi-thread use.
: In "MicroSoft" Win32 API, SendMessage to other thread will suspend
: self.
: If there are two threads: A and B, A send message to B(call SendMessage)
: 
: and at the same time B call SendMessage to send message to A. A and B
: both suspend themselves.There is a deadlock.
: How "MicroSoft" solves it? Does anybody know?

This is one of those things that is so simple in concept, yet so complicated
in implementation.  Simple SendMessage hides required complex
asynchronous message passing, task switching, and parameter copying.

The simple answer to your question is:  there are separate message
queues associated with each task.  When SendMessage is called
on a non-local task, the system copies the parameters to the task's
message queue, and calls a low-level special scheduler function
known as DirectedYield(), which not only task-switches to the new
task, but also states where to start execution, which happens to be a
stub that reads messages from it's task queue.  This stub
reads the parameters from the queue, and starts a local SendMessage.
Should this task call SendMessage, the entire process recurses on 
each respective task's stackframe... ;-0

See win32 api DirectedYield, ReplyMessage and "Windows Internals" by
Matt Pietrek for more information.

I plan on implementing inter-task SendMessage, but didn't yet want
to bring in multithreading into Microwindows.

Greg
Subject: Re: how to SendMessage?
From: ShenChong ####@####.####
Date: 19 Nov 1999 03:56:48 -0000
Message-Id: <3834C8EB.5E44DE0@term.star.com.cn>

Thank for your quick response.

Greg Haerr wrote:

>  This stub
> reads the parameters from the queue, and starts a local SendMessage.
> Should this task call SendMessage, the entire process recurses on
> each respective task's stackframe... ;-0

What does it mean?

I can't find DirectedYield in MSDN Win32 API. What's it?

Subject: Re: how to SendMessage?
From: Ben Pfaff ####@####.####
Date: 19 Nov 1999 03:59:26 -0000
Message-Id: <87vh6zb0ht.fsf@pfaffben.user.msu.edu>

ShenChong ####@####.#### writes:

> I can't find DirectedYield in MSDN Win32 API. What's it?

IvaguelySTR from my many-years-ago experience in Windows16
programming that it switches to a particular task rather than to
one selected by the (cooperative) scheduler.
-- 
"I consider that the golden rule requires that if I like a program
 I must share it with other people who like it."
--Richard Stallman
[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.