Closed jeehoonkang closed 4 years ago
PushReq
with four possible tags: 0, 1, 2, 3.
try_push()
thread::sleep(ELIM_DELAY)
.try_pop()
thread::sleep(ELIM_DELAY)
.in try_push()
Check if the slot is collided; if so, return. (Don't touch the slot and the push request.)
Why not clean up the slot? A pop should've collided and returned by now, there would be no one to clean it up if the push just returns.
@hydium A collision implies there is a pop()
thread colliding against the push()
thread you mentioned. Then, the pop()
thread seems to be responsible for cleaning up and freeing the PushReq
.
@hyunsukimsokcho But then, how does the push() thread know what happened after waking up? After the pop() thread cleans the slot up, it can be reused by other threads and be in an arbitrary state.
@hydium I see your point. Maybe pop()
thread only frees PushReq
and push()
thread CAS the tag to 0. Then, whether there is a collision can be known by checking PushReq || tag == 3
. (It is not a trivial implication from the provided spec. by prof.)
I knew that the dead line is 2019-12-23 21:00:00. But, in "gg.kaist.ac.kr" the dead line is "2019-12-23 09:00:01". Is it wrong or just I know wrong information?
I knew that the dead line is 2019-12-23 21:00:00. But, in "gg.kaist.ac.kr" the dead line is "2019-12-23 09:00:01". Is it wrong or just I know wrong information?
Don't worry, It means 21:00:01. (9:00:01 PM)
I uploaded the scores. Grading criteria is as follows.
If you're stack doesn't eliminate at all, I deducted 70%. If your program leaks memory, you'll get partial credits (10pts); if your program crashes, you'll get no credits.
References