hello, i am working on implementing the elevator simulation problem in C for my assign. Here we have to deal wit a clock thread, thread for each work in the building and a monitor structure to manage the elevator. I am trying to figure how to keep track of everything, hence trying to understand how to implement multithreading properly.
my first step was to make the elevator work with only the clock thread, but i dont know if my approach is right. this is what i am doing...can u let me know if my approach is correct...i think u can help students out by telling if there approach is atleast correct
my clock thread will be responsible for checking the current position of the elevator. if it is on the ground floor it will go up, if it is on the top floor it will go down. if it is somewhere in between, based on a random value it will either go up or down. what i dont get ism will my clock thread keep track of actual time or i can setup my own clock which initializes whenever i run my program and keep track of where the elevator is after each clock period?
also, since for now, i only have a clock thread, do i need to take care of any synchornzation issues?? or do we handle them when we bring the people threads into the code?
hope to hear from u soon!!