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: 25
Joined: Thu Feb 17, 2011 4:58 pm
Location: US

Threading issue

Post by jwong » Tue Apr 12, 2011 10:25 am

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 » Thu Apr 14, 2011 8:47 pm

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 » Fri Apr 15, 2011 12:33 pm

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 » Sat Apr 16, 2011 9:02 am

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: 25
Joined: Thu Feb 17, 2011 4:58 pm
Location: US

Re: Threading issue

Post by jwong » Mon Apr 25, 2011 11:56 am

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