Jump to page: 1 2
Thread overview
send doesn't work
Nov 15, 2016
unDEFER
Nov 15, 2016
Daniel Kozak
Nov 15, 2016
unDEFER
Nov 15, 2016
unDEFER
Nov 15, 2016
unDEFER
Nov 15, 2016
unDEFER
Nov 16, 2016
unDEFER
Nov 16, 2016
unDEFER
Nov 16, 2016
Era Scarecrow
Nov 16, 2016
unDEFER
Nov 16, 2016
Anonymouse
Nov 17, 2016
unDEFER
November 15, 2016
Hello!
In my thread I'm sending the Tid of the thread to the parent to inform it about finishing:
send(tid, thisTid);

The parent thread has the next code to receive it and handle:
receiveTimeout( dur!"hnsecs"(1),
                (Tid tid)
                {//the message from child thread handler} );

It is good works for my first child thread.
But, some times ago I have added the second child thread (no, no, the first thread and the second thread works not simultaneously) and have found that the receiving message doesn't work! The parent doesn't get the message although the child sends it.
So in my code have appeared the next insertion in the start of thread:
/* Strange, but without sending message
       at start thread makes not working
       sending at end thread */
    send(tid, "Hello");

Now I have added the third child thread. At the first it have worked good, but now it again doesn't receive the message. And "send hello"-hack doesn't help.
What to do? Why the sending of the message may doesn't work?
November 15, 2016
Dne 15.11.2016 v 17:36 unDEFER via Digitalmars-d napsal(a):

> Hello!
> In my thread I'm sending the Tid of the thread to the parent to inform it about finishing:
> send(tid, thisTid);
>
> The parent thread has the next code to receive it and handle:
> receiveTimeout( dur!"hnsecs"(1),
>                 (Tid tid)
>                 {//the message from child thread handler} );
>
> It is good works for my first child thread.
> But, some times ago I have added the second child thread (no, no, the first thread and the second thread works not simultaneously) and have found that the receiving message doesn't work! The parent doesn't get the message although the child sends it.
> So in my code have appeared the next insertion in the start of thread:
> /* Strange, but without sending message
>        at start thread makes not working
>        sending at end thread */
>     send(tid, "Hello");
>
> Now I have added the third child thread. At the first it have worked good, but now it again doesn't receive the message. And "send hello"-hack doesn't help.
> What to do? Why the sending of the message may doesn't work?
Yous should post this into Learn news group not in General. And it would be better if you provided full (not)working example.

and I guess you have this

receiveTimeout( dur!"hnsecs"(1),
                (Tid tid)
                {//the message from child thread handler} );

in some while(true) loop?
November 15, 2016
On 11/15/16 11:36 AM, unDEFER wrote:
> Hello!
> In my thread I'm sending the Tid of the thread to the parent to inform
> it about finishing:
> send(tid, thisTid);
>
> The parent thread has the next code to receive it and handle:
> receiveTimeout( dur!"hnsecs"(1),
>                 (Tid tid)
>                 {//the message from child thread handler} );
>
> It is good works for my first child thread.
> But, some times ago I have added the second child thread (no, no, the
> first thread and the second thread works not simultaneously) and have
> found that the receiving message doesn't work! The parent doesn't get
> the message although the child sends it.
> So in my code have appeared the next insertion in the start of thread:
> /* Strange, but without sending message
>        at start thread makes not working
>        sending at end thread */
>     send(tid, "Hello");
>
> Now I have added the third child thread. At the first it have worked
> good, but now it again doesn't receive the message. And "send
> hello"-hack doesn't help.
> What to do? Why the sending of the message may doesn't work?

Without more complete code, it's difficult to say what is happening.

-Steve
November 15, 2016
Now I'm sending "hello"-message from child thread in the loop every iteration, and the last message again working.
What the magic??? The send-subsystem "becomes rotten" if don't use it???
November 15, 2016
On Tuesday, 15 November 2016 at 18:12:32 UTC, Steven Schveighoffer wrote:
> Without more complete code, it's difficult to say what is happening.
>
> -Steve

Code is big. I of course can return to the question when the code will available on the git. But now it is not available.
November 15, 2016
On Tuesday, 15 November 2016 at 18:11:38 UTC, Daniel Kozak wrote:

> Yous should post this into Learn news group not in General. And it would be better if you provided full (not)working example.

If the problem will appears again I will try to make short not working example..

> and I guess you have this
>
> receiveTimeout( dur!"hnsecs"(1),
>                 (Tid tid)
>                 {//the message from child thread handler} );
>
> in some while(true) loop?

Of course there is while(!gs.finish) :-)
November 15, 2016
On 11/15/16 1:13 PM, unDEFER wrote:
> Now I'm sending "hello"-message from child thread in the loop every
> iteration, and the last message again working.
> What the magic??? The send-subsystem "becomes rotten" if don't use it???

1. I'm sure it's not "magic" but likely something you are missing.
2. Nobody here can help you without a working demonstration. i.e., this isn't a known issue, and others have used the concurrency subsystem without such problems.

If you construct a small example that demonstrates the problem, that is helpful for diagnosis (or better yet, may demonstrate to you why it's not working in your full codebase).

-Steve
November 15, 2016
On Tuesday, 15 November 2016 at 18:23:16 UTC, Steven Schveighoffer wrote:
> 1. I'm sure it's not "magic" but likely something you are missing.
> 2. Nobody here can help you without a working demonstration. i.e., this isn't a known issue, and others have used the concurrency subsystem without such problems.
>
> If you construct a small example that demonstrates the problem, that is helpful for diagnosis (or better yet, may demonstrate to you why it's not working in your full codebase).
>
> -Steve

So, the problem still here. Sometimes it is working with hello-messages, but sometimes doesn't work.
I will try to make minimal application. But I don't know still what it must do. Trying to minimize the main thread to starter of the second thread shows that the problems goes away..
So it will really not easy, but I will try...
Thank you.
November 15, 2016
On 11/15/16 1:56 PM, unDEFER wrote:
> On Tuesday, 15 November 2016 at 18:23:16 UTC, Steven Schveighoffer wrote:
>> 1. I'm sure it's not "magic" but likely something you are missing.
>> 2. Nobody here can help you without a working demonstration. i.e.,
>> this isn't a known issue, and others have used the concurrency
>> subsystem without such problems.
>>
>> If you construct a small example that demonstrates the problem, that
>> is helpful for diagnosis (or better yet, may demonstrate to you why
>> it's not working in your full codebase).
>
> So, the problem still here. Sometimes it is working with hello-messages,
> but sometimes doesn't work.
> I will try to make minimal application. But I don't know still what it
> must do. Trying to minimize the main thread to starter of the second
> thread shows that the problems goes away..
> So it will really not easy, but I will try...
> Thank you.

From experience, this smells like a race condition. I'd try removing features of your program until it starts working, then you may have your answer.

I'd suggest dustmite may help, but in the case of non-deterministic failure, it's more difficult to have it work.

-Steve
November 16, 2016
Really situation is much more interesting:
Sometimes I got Tid not the same as sent.
Sometimes I receive 2 TID although sent only 1.
« First   ‹ Prev
1 2