Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Win32 thread primitives
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vladimir Lipsky  
View profile  
 More options May 2 2005, 7:52 am
Newsgroups: perl.perl6.internals
From: searcher...@rambler.ru (Vladimir Lipsky)
Date: Mon, 2 May 2005 15:52:39 +0400
Local: Mon, May 2 2005 7:52 am
Subject: [Patch] Win32 thread primitives

This patch defines Win32 thread primitives. Actually it consists of the
following files:

 threads.h.diff
 thr_windows.h.diff
 threads.t.diff
 timer.t.diff

The patch had been applied, I mananged to pass all the tests from
t/pmc/thread.reast and t/pmc/timer.t but thread_4.pasm(don't know yet why it
fails)

The other files are needed the patch to compile and work properly:

events.c.diff - contains fix for correct deteremination of the tv_nsec
value. Now it is always equal to zero.
imcc.l.diff, imcc.y.diff et al - contain a dirty hack which prefixes the
CONST lexeme with underscore, otherwise CONST conflicts with MACRO from
windows header files. Probably the solution wwould be to prefix all the
lexemes with IMCC_ or whatever. Prefixing should be done for thread
primitives either.

  events.c.diff
< 1K Download

  imcc.l.diff
< 1K Download

  imcc.y.diff
1K Download

  imclexer.c.diff
< 1K Download

  imcparser.c.diff
1K Download

  imcparser.h.diff
< 1K Download

  main.c.diff
< 1K Download

  thr_windows.h.diff
4K Download

  threads.h.diff
< 1K Download

  threads.t.diff
< 1K Download

  timer.t.diff
< 1K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leopold Toetsch  
View profile  
 More options May 2 2005, 8:44 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Mon, 02 May 2005 14:44:52 +0200
Local: Mon, May 2 2005 8:44 am
Subject: Re: [Patch] Win32 thread primitives

Vladimir Lipsky wrote:
> This patch defines Win32 thread primitives.

Great.

> ...Actually it consists of the
> following files:

> threads.h.diff
> thr_windows.h.diff
> threads.t.diff
> timer.t.diff

Small nitpick - please provide just one patch file - applying is much
simpler then, or less work ;)

> The patch had been applied, I mananged to pass all the tests from
> t/pmc/thread.reast and t/pmc/timer.t but thread_4.pasm(don't know yet
> why it fails)

threads_4 is testing killing threads. This is achieved by scheduling a
terminate event to the running interpreter. This can only succeed, if
the event system is running too.
see src/events.c/Parrot_new_terinate_event()

> imcc.l.diff, imcc.y.diff et al - contain a dirty hack which prefixes the
> CONST lexeme with underscore, otherwise CONST conflicts with MACRO from
> windows header files. Probably the solution wwould be to prefix all the
> lexemes with IMCC_ or whatever. Prefixing should be done for thread
> primitives either.

Argh, yes. Can you just #undef the CONST after including the windows.h?

leo


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vladimir Lipsky  
View profile  
 More options May 3 2005, 1:59 am
Newsgroups: perl.perl6.internals
From: searcher...@rambler.ru (Vladimir Lipsky)
Date: Tue, 3 May 2005 09:59:18 +0400
Local: Tues, May 3 2005 1:59 am
Subject: Re: [Patch] Win32 thread primitives

> threads_4 is testing killing threads. This is achieved by scheduling a
> terminate event to the running interpreter. This can only succeed, if the
> event system is running too.
> see src/events.c/Parrot_new_terinate_event()

Though thr_windows.h doesn't contain error checking for now, it luckily
fails when the killed thread returns from runops and tries to LOCK the
interpreter_array_mutex. But before that the thread of the main interp had
time to call Parrot_really_destroy, loop interpreter_array, and free
interpreter_array_mutex. Here I see two solutions:
A) do not free the array and mutex asscociated with it at all; those are
global, malloced once, have no destructor, would it be a memory leak?
B) the very last thread do the work, it iterates thru array and if all tids
are null(except itself), free array and mutex.

On the another hand I didnt see that interpreters task queues and mutexes of
the shared pmc's(sub and Interp, probably) were freed up anywhere. It's that
normal?

And on the third hand, if I understood the code correctly ...

src/threads.c: 40: thread_func()
src/threads.c: 53: interpreter->thread_data->state |= THREAD_STATE_FINISHED;

src/threads.c: 312: pt_thread_join ()
src/threads.c: 321: if (interpreter->thread_data->state ==
THREAD_STATE_JOINABLE ||
src/threads.c: 322:     interpreter->thread_data->state ==
THREAD_STATE_FINISHED) {

src/threads.c: 453: detach()
src/threads.c: 462: if (interpreter->thread_data->state ==
THREAD_STATE_JOINABLE ||
src/threads.c: 463:     interpreter->thread_data->state ==
THREAD_STATE_FINISHED) {

lines 322, 463 never hold true, because of line 53. So pt_thread_join,
detach are never able do their work on threads that have runops-ed.

> Argh, yes. Can you just #undef the CONST after including the windows.h?

Ok, done it.

  win32_threads.patch
5K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leopold Toetsch  
View profile  
 More options May 3 2005, 4:21 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Tue, 03 May 2005 10:21:56 +0200
Local: Tues, May 3 2005 4:21 am
Subject: Re: [Patch] Win32 thread primitives

Vladimir Lipsky wrote:
>> threads_4 is testing killing threads. This is achieved by scheduling a
>> terminate event to the running interpreter. This can only succeed, if
>> the event system is running too.
>> see src/events.c/Parrot_new_terinate_event()

> Though thr_windows.h doesn't contain error checking for now, it luckily
> fails when the killed thread returns from runops and tries to LOCK the
> interpreter_array_mutex. But before that the thread of the main interp
> had time to call Parrot_really_destroy, loop interpreter_array, and free
> interpreter_array_mutex.

This case can be considered as a programmers error (we should guard
against it if possible, though). When the "main" or first interpreter
terminates the packfile with the opcodes is destroyed. A still running
thread wouldn't have any more code to execute.

> ... Here I see two solutions:
> A) do not free the array and mutex asscociated with it at all; those are
> global, malloced once, have no destructor, would it be a memory leak?
> B) the very last thread do the work, it iterates thru array and if all
> tids are null(except itself), free array and mutex.

B) if any, but it's not only freeing the interpreter array. The last one
has to do all the work that the main interpreter should have done.

See also src/inter_create.c:Parrot_really_destroy()

> On the another hand I didnt see that interpreters task queues and
> mutexes of the shared pmc's(sub and Interp, probably) were freed up
> anywhere. It's that normal?

There are presumably some more leaks in the code, yes - err no ;-)

I don't think so: in line 47 the thread enters the runloop, state is
JOINABLE (except when created detached). Another thread, which has the
TID of the thread  can now join or detach it. Only when the thread
leaves its runloop, it's state is set to FINISHED. So at e.g. line 322
it can be JOINABLE (still running) or FINISHED. The JOIN() then gets the
return result, which possibly causes the caller to wait for the thread
to finish.

>> Argh, yes. Can you just #undef the CONST after including the windows.h?

> Ok, done it.

Good.

Thanks, applied
leo


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vladimir Lipsky  
View profile  
 More options May 3 2005, 5:35 am
Newsgroups: perl.perl6.internals
From: searcher...@rambler.ru (Vladimir Lipsky)
Date: Tue, 3 May 2005 13:35:19 +0400
Local: Tues, May 3 2005 5:35 am
Subject: Re: [Patch] Win32 thread primitives

It's state is set to PREVIOUS_STATE+FINISHED
So it's never equal to just FINISHED

>> src/threads.c: 53: interpreter->thread_data->state |=
>> THREAD_STATE_FINISHED;
>> src/threads.c: 322:  interpreter->thread_data->state ==
>> THREAD_STATE_FINISHED) {

Typo or what?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leopold Toetsch  
View profile  
 More options May 3 2005, 6:13 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Tue, 03 May 2005 12:13:45 +0200
Local: Tues, May 3 2005 6:13 am
Subject: Re: [Patch] Win32 thread primitives

Vladimir Lipsky wrote:
> It's state is set to PREVIOUS_STATE+FINISHED
> So it's never equal to just FINISHED

Ah, Yep. Works for JOINABLE, which is 0, but ...

> Typo or what?

Inexact ;-)

leo


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google