Threading issue

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
jwong
Level 2
Level 2
Posts: 27
Joined: Thu Feb 17, 2011 4:58 pm

Threading issue

Post by jwong »

I have both a Windows app and a Cocoa Mac app. I am going to have my Windows app run under Wine on OSX. I would like the Mac app to trigger an event in my Windows app. I have thus far been able to accomplish this with use of the Cocoa NSDistributedNotificationCenter.

To give a little background, my Windows app loads a winelib dll which has a handler for a specific NSNotification and calls a function in my Windows app. The winelib dll is passed a function pointer (for now lets call it myfunc()) during startup. Simple memory operations work great within myfunc(). I am able to modify and view simple global variables in my Windows app such as integers (I havent tried a C++ class). The problem is I cannot perform operations such as creating a new thread (using afxbeginthread()) within my Windows app or use EnterCriticalSection() and LeaveCriticalSection(). Whenever I call any of these function the thread appears to get stuck in an infinite loop. I know a thread has been created and hangs because the CPU usage instantly increases to roughly 70% and never decreases as soon as the handler is called.

Note: if I call myfunc() directly from within my Windows code, myfunc() operates as expected (no hanging or increase in CPU usage).
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: Threading issue

Post by vitamin »

jwong wrote:The problem is I cannot perform operations such as creating a new thread (using afxbeginthread()) within my Windows app or use EnterCriticalSection() and LeaveCriticalSection().
Of course you can't. You can not mix synchronization operations of Wine and native system. It won't ever work properly.

The only way you can do this is via some sort of IPC. For example stdin/stdout, pipes, socket.
James McKenzie

Threading issue

Post by James McKenzie »

On 4/14/11 6:47 PM, vitamin wrote:
jwong wrote:
The problem is I cannot perform operations such as creating a new thread (using afxbeginthread()) within my Windows app or use EnterCriticalSection() and LeaveCriticalSection().
Of course you can't. You can not mix synchronization operations of Wine and native system. It won't ever work properly.

The only way you can do this is via some sort of IPC. For example stdin/stdout, pipes, socket.
Are named pipes available through Wine? That may be the best option in
this case.

James McKenzie
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: Threading issue

Post by vitamin »

James McKenzie wrote:Are named pipes available through Wine?
Wine named pipes are not 100% implemented - they still don't support message mode. And are implemented via socket.
jwong
Level 2
Level 2
Posts: 27
Joined: Thu Feb 17, 2011 4:58 pm

Re: Threading issue

Post by jwong »

Of course you can't. You can not mix synchronization operations of Wine and native system. It won't ever work properly.

I was afraid of that but thanks for the answer.
Locked