Hi everyone,
I'm new here ... haven't had my warm welcome yet ;P
So i need your help with my program. I'm supposed to program a simulator of the reader writer problem without using threads. So i thought i could use a timer to interrupt the running process every 2 seconds to see if other processes want to enter the critical section (which is in my case a txt file where readers and writers manipulates data) like a trap and i can do what i want in the routine... and all of this is to show the use of semaphores.
The question is, is such timer possible? can i do that? and how ?
Can someone help me plz :)
zidaneez
0
Newbie Poster
Recommended Answers
Jump to PostCan't help much with the code. It looks Microsoft-specific? But I don't see where you're creating separate processes. I see Reader and Writer objects being created, but no separate Reader and Writer processes? Maybe I'm missing something.
I'm a little confused as to what you want to do with …
Jump to PostYou're welcome. This won't serve your needs, but might be helpful if you're brand new to signals. Your signal interrupt would be timer based, not user input based and you'd perhaps use SIGUSR1 or SIGUSR2 rather than SIGINT.
Jump to Post>> to be able to interrupt the execution of a process in the critical section
That's what signals do. They interrupt the program flow of the receiving process. In particular, they can wake up a sleeping process. A process tries to enter, can't, goes to sleep, then later, when …
Jump to PostOk, but where to issue the signal?? In a multi threaded program it's more than fine. yet i don't see how it's efficient in a single threaded program like mine!
That's where I come back to my original question a few posts back. Your program is not only single-THREADED, but …
All 13 Replies
alexchen
-12
Junior Poster
zidaneez
0
Newbie Poster
VernonDozier
2,218
Posting Expert
Featured Poster
zidaneez
0
Newbie Poster
zidaneez
0
Newbie Poster
VernonDozier
2,218
Posting Expert
Featured Poster
VernonDozier
2,218
Posting Expert
Featured Poster
zidaneez
0
Newbie Poster
VernonDozier
2,218
Posting Expert
Featured Poster
zidaneez
0
Newbie Poster
VernonDozier
2,218
Posting Expert
Featured Poster
zidaneez
0
Newbie Poster
VernonDozier
2,218
Posting Expert
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.