NO

Author Topic: to Thread or not to PosixThread  (Read 4990 times)

liquiz

  • Guest
to Thread or not to PosixThread
« on: February 15, 2007, 08:39:10 AM »
Hello Everyone,

Im getting ready to start up a new project at work, something to replace one I did over a year ago.

One of the problems I find myself running into is the amount of memory the older program is using.  So I was looking at different ways to get around that, while at the same time improving on the functionality of what I already have.

In a nutshell the program is a data integrity tool that reads and writes to a specified file.  One instance, one file, one process ... a very linear approach.

I use several small mallocs to setup read/write buffers but one big malloc to maintain a "virtual" list of where I need to read and write from.  I use that list to ensure I have written to every block in that file.  99% of the code is Ansi C, I try very hard to avoid windows specific calls/library functions, thats allowed me to port this to linux with verfy few ifdefs to isolate windows or linux only code.

In an effort to cut down on the # of large mallocs I was thinking about going to one main process that tracked and handled the large list while smaller processes handle the read/write portion.  The idea being the smaller process checks out a section to work with and then checks back in the results before checking a new task back out.  This means data has to flow both directions.

--

So now to the meat of the question.  
Is the threading thats in Pelles C posix compliant
Will Pelles C work with http://sourceware.org/pthreads-win32/

Peace

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: to Thread or not to PosixThread
« Reply #1 on: February 16, 2007, 01:21:29 PM »
Quote from: "liquiz"
Is the threading thats in Pelles C posix compliant
Will Pelles C work with http://sourceware.org/pthreads-win32/

I havn't tried this package, so this is just a guess: "it should work".

Critical sections are used for Pelles C runtime function like malloc(), realloc() etc. This should work even if you use pthreads-win32. If you use _beginthread[ex](), a buffer will be allocated for each thread to keep thread specific data - but - the C runtime will attempt to recover by allocating this buffer "when needed". So even if you use pthreads-win32 to create threads, things "should work". But again, I havn't tried it...
/Pelle