Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2013-12

pthread scheduler attributes

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Henry Vermaak
to Michael Van Canneyt
Michael Van Canneyt wrote 10 lines
On Tue, 10 Dec 2013, Henry Vermaak wrote: >Hello everyone > >Could anyone tell me why threads are set to not inherit scheduling >parameters from the calling thread? > >http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/unix/cthreads.pp?view=markup#l339 No particular reason. Probably because it tries to mimic windows behaviour.

I thought Windows threads always start with the same priority as the process?

I also just noticed that this code probably leaks memory, since pthread_attr_destroy() is never called for thread_attr.

Henry

Reply by email

Sven Barth
to Henry Vermaak
"Henry Vermaak" wrote 10 lines
On Tue, Dec 10, 2013 at 12:27:00PM +0100, Michael Van Canneyt wrote: > On Tue, 10 Dec 2013, Henry Vermaak wrote: > > >Hello everyone > > > >Could anyone tell me why threads are set to not inherit scheduling > >parameters from the calling thread? > > > >

http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/unix/cthreads.pp?view=markup#l339

> > No particular reason. Probably because it tries to mimic windows

behaviour.

I thought Windows threads always start with the same priority as the process?

Yes and no. On windows processes have a process class and threads have a priority level. Threads inherit the priority class from the process (and this can not be changed on a per thread level) and are created with priority level THREAD_PRIORITY_NORMAL *within* that priority class. Changing the priority level then only changes the priority level *inside* the priority class.
Don't know how good this Windows behavior is approximated on cthreads systems though... (and I don't really know wether it's good to approximate it :/ )

Regards,
Sven

Reply by email

Henry Vermaak
to Sven Barth
Sven Barth wrote 13 lines
Am 10.12.2013 12:51 schrieb "Henry Vermaak" : > I thought Windows threads always start with the same priority as the > process? Yes and no. On windows processes have a process class and threads have a priority level. Threads inherit the priority class from the process (and this can not be changed on a per thread level) and are created with priority level THREAD_PRIORITY_NORMAL *within* that priority class. Changing the priority level then only changes the priority level *inside* the priority class. Don't know how good this Windows behavior is approximated on cthreads systems though... (and I don't really know wether it's good to approximate it :/ )

OK, thanks. I can't think of a straight forward way to abstract the policies and priorities. Since it's quite a specialised thing to do and the policy/priority (at least on linux) depends on the system and what else is running on it, perhaps it's not unreasonable to let the user write platform specific code for their use case.

Not inheriting the policy/priority on linux is definitely unexpected, though, I only found out after reading the code in cthreads. Does anyone agree with me here? Shall I file a bug report?

I'll file a bug report for the leak.

Henry

Reply by email