1.
thread1:
add to list
increment
thread2
add to list
increment
if the requirement is thread muxing ie 2 threads --> 1 thread processing
best implementation is
lock
add to list
if( increment ) {
release
}
else {
release
}
otherwise at cpu register level there should be an atomic xchange like cmd
any two register values modified complete state cannot be determined using single register
on the processing side ,with the above construct one variable can determine state
since incr and addlist is done atomic
========================
main process and deinit
deinit:
set flag
check if process increment flag is 0 else loop
proceed
process:
if flag do nothing
else carry on
No comments:
Post a Comment