On Thu, Jun 24, 2010 at 7:25 PM, Massimiliano Pala <
massimiliano.p...@dartmouth.edu> wrote:

> Hi all,
>
> I have a question for Win coders.. I am porting LibPKI, which is based on
> OpenSSL, to Win OSes. On UNiX OSes we used pthread to initialize support
> for threads in OpenSSL.
>
> What is the best practice for Win OS ? Does anybody have some sample code
> around ? In particular, I am referring to the code like:
>

It depends. Usually, my work had to build on multiple platforms after I was
done, so it was handy to have as little platform-specific code in there as
possible (time restraints and all that), in which case there's a nice
pthreadsWin32 port around so the rest of your code can remain 'platform
agnostic' in a way.

If your final product has to run on Win32/64 only, I suggest going with
Jeffrey Walton's suggestion by going native.
If performance is an issue, you might consider his suggestion too, though
run-time gains will be superficial / political.

In the end it's weighting the maintenance costs versus current time
restraints and project [management] demands, plus your own preference/taste.
pthreadsWin32 is just a pthreads API built on top of those same Win32/64
native locking primitives, so in the end it's just a matter of more or less
transformation/call overhead with each run-time lock request
(pthreads:little or native:none).

When done the 'native' way, I've almost always used critical sections, due
to the reasoning already mentioned by Mr. Watson. Besides, they're faster
than mutexes.

-- 
Met vriendelijke groeten / Best regards,

Ger Hobbelt

--------------------------------------------------
web:    http://www.hobbelt.com/
       http://www.hebbut.net/
mail:   g...@hobbelt.com
mobile: +31-6-11 120 978
--------------------------------------------------

Reply via email to