I have a circular linked list, each child thread only need to read the data in the linked list nodes, but there are times when the main thread to rewrite cycle node in the list, Every time I design train of thought is the main thread to rewrite the linked list node need to enter the critical section, rewrite the complete leave, consult bosses read the child thread linked list node data may not be critical section? If you need to add critical region, then assign each child thread a circular linked list whether efficiency will be higher? (if need to use TLS, so the main thread to access each thread in the TLS circular linked list?)
CodePudding user response:
Lock safer, but efficiency is not high, can know about the read-write lock; Assign each child thread a circular linked list, also involves the data synchronization problem, efficiency should be even worse
CodePudding user response:
Modify the data of the main thread is only one? If the child thread without didn't need to add the main thread, because modify the data of the main thread is only one, no one to grab it, there is no conflict, You are communal circular linked list data? If it is a common, you assign to each child thread a circular linked list, so the main thread all child threads need to update the list every time, every time want to compete with all the child thread, a list of words is the main thread, competition between all the child thread; Multiple chain table is the main thread and the competition between each child threads, feel less than where high efficiency,