4
votes
Accepted
pattern to unlock thread and get variable in fast unlock
The basic problem here seems to be that this thread keeps the mutex locked by default, and only unlocks it for a limited period of time when it's sure it doesn't need to the mutex.
Normally, you want ...
4
votes
pattern to unlock thread and get variable in fast unlock
In this function, you lock mutex and keep it locked except for a tiny part, where you do_something, letting the other threads aquire the mutex, before waiting to re-lock it.
What's wrong ?
When ...
3
votes
C Thread Architecture
From a purely conceptual standpoint, main() is no different than any other thread in the same process. It just happens to be the one that was started first but still shares code and data with every ...
2
votes
Where to initialize clients in C server?
Whenever one has a requirement which does not fit into the existing module structure of a system, I would recommend to start with a new module first.
Said that, during the evolution of this new module,...
2
votes
Should I introduce a controller layer to separate networking from game/player logic in a C server project?
The closest I ever got to C is writing some procedural C++ in college, and I don't build games, so my answer isn't going to provide the exact structure; instead it will describe the approach I would ...
2
votes
Accepted
How to handle errors of pthreads fundamental lock und unlock functions?
Nobody handles this error conditions. That they return errors is a typical DesignByComitee problem. The only way to handle them is to crash your process and move error handling to a whole other level. ...
1
vote
Where to initialize clients in C server?
The logic that you describe looks very much like session management, the glue that ties together network connection with a user.
As it is a different concern than the ones handled in other modules, ...
1
vote
How to handle errors of pthreads fundamental lock und unlock functions?
Read the pthread documentation and see what errors each function can return. Hopefully there is also a hint there what the best way is to handle such an error.
Depending on the kind of error, that ...
1
vote
How should functions that keep state across multiple invocations be made safe?
In the example in case 2, according to the solution in the quote, should the "rand()" function be changed to "unsigned rand(unsigned next_seed)"?
/* rand - return pseudorandom ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
pthreads × 11multithreading × 6
c × 5
architecture × 2
c++ × 2
parallelism × 2
design × 1
design-patterns × 1
api-design × 1
concurrency × 1
linux × 1
server × 1
game-development × 1
c++11 × 1
sockets × 1
parallel-programming × 1
runtime × 1
software-schedules × 1
c11 × 1