There is one thread and only one thread which will be writing/modifying a data structure. The data structure has one field which is a socket descriptor opened by the writing thread. Two other threads will be reading the data structure and will have to do something (like polling the socket(s) stored in the structure for input data).
One thread will read one global structure written by the writing thread while the other thread will read a second global structure. In essence, the two reading threads are not accessing the same global structure.
My question is, if the writing thread makes changes to the data structure which maybe adding more records in the data structure or deleting them, will the process crash? Is there any room for any kind of instance where a run-time crash can occur?
P.S. I’m using POSIX Threads working on a Linux environment
Short answer: most likely yes. You need to protect the data structure with some kind of locking. Pthread mutexes come to mind.
Longer answer: Think about a linked list. Think about adding an element or deleting one. Typically you need to modify more than one aspect of that list, for example you need to modify 2 pointers. Now ask yourself: what will happen if:
nextpointer) but isn’t quite done before it gets interruptedEDIT
As Blagovest Buyukliev mentions in the comments, lock-free data structures usually provide more performance so you could investigate that route.