Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

reader-writer-problem

Name: Anonymous 2009-05-19 17:06

I don't expect much code, actually not any code at all, but my mind is currently blank.
What's a better solution than the trivial one (writers wait for all readers to finish)?
I don't really like to use a timer, so do you think it would be a good idea to let the writers do their job every x readers?
The program will be written in C, using pthreads.

Also I know /prog/ won't do my assignment, I just need an idea, or verification if mine would do.

Name: Anonymous 2009-05-19 18:05

higher default priority to writers + implement aging for all

Name: Anonymous 2009-05-19 18:51

use file locking

doers_thread {
    when (must_do) {
        wait_for_do (file);
        flock (file);
        for (doers)
            do();
        funlock (file);
    }
}
add_do_thread (readers_thread, reading);
add_do_thread (writers_thread, writing);

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List