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:
Anonymous2009-05-19 17:18
Do it using coroutines, problem solved.
Name:
Anonymous2009-05-19 17:21
select
Name:
Anonymous2009-05-19 17:24
Do it using STM, problem solved.
Name:
Anonymous2009-05-19 17:29
what are the writers writing? what are the readers reading?
Name:
Anonymous2009-05-19 17:30
How many are the writers and readers?
Name:
Anonymous2009-05-19 18:05
higher default priority to writers + implement aging for all
Name:
Anonymous2009-05-19 18:37
Use Erlang, problem solved.
Name:
Anonymous2009-05-19 18:44
>>2,4
No. >>3 select doesn't work this way. >>5
Lines from a text file. >>6
Dynamic, passed by the command line. Also the amount of cycles is passed on the command line, i.e. how many read (or write for writer-threads) operations each thread does.
Imagine the command line ./reader-writer <cycles> <reader-threads> <writer-threads>. >>7
This seems interesting. But will it work efficiently if each thread does the same amount of reads/writes? It's quite a basic problem, so I don't know if that would be kind of an overkill.
Name:
Anonymous2009-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);
Actually I made this more complex for me than it was.
There was another trivial solution all along, not preferring the readers, by simply just using one mutex.
I'll be back to reading my SICP, sorry to have bothered you, >>7,10.
Name:
Anonymous2009-05-19 19:28
A simple solution is to don't allow anymore readers when a writer wants to write. This way the readers can't starve the writers.
Name:
Anonymous2009-05-19 19:48
>>13
I must not fear
Fear is the mind killer
Fear is the little death that will bring total obliteration
I will face my fear
I will permit it to pass over me and through me
And when it has gone, I will turn the inner eye to see its path
Where the fear has gone, there will be nothing
Only I remain
Name:
Anonymous2009-05-19 20:30
I must not fear
Fear is the mind killer
Fear is the little death that will bring total obliteration
I will face my fear
I will permit it to pass over me and through me
And when it has gone past, I will turn the inner eye to see its path
Where the fear has gone, there will be nothing
Only I will remain