nanogui: how to SendMessage?


Previous by date: 19 Nov 1999 02:54:13 -0000 how to SendMessage?, ShenChong
Next by date: 19 Nov 1999 02:54:13 -0000 Re: how to SendMessage?, ShenChong
Previous in thread: 19 Nov 1999 02:54:13 -0000 how to SendMessage?, ShenChong
Next in thread: 19 Nov 1999 02:54:13 -0000 Re: how to SendMessage?, ShenChong

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

Previous by date: 19 Nov 1999 02:54:13 -0000 how to SendMessage?, ShenChong
Next by date: 19 Nov 1999 02:54:13 -0000 Re: how to SendMessage?, ShenChong
Previous in thread: 19 Nov 1999 02:54:13 -0000 how to SendMessage?, ShenChong
Next in thread: 19 Nov 1999 02:54:13 -0000 Re: how to SendMessage?, ShenChong


Powered by ezmlm-browse 0.20.