Interview Question
Senior Software Development EngineersCountry: United States
Interview Type: In-Person
For Repeated company name the directory will be created only once and files will be moved to that directory. But there can be case when two thread having the same company name are executing in parallel then we need to implement synch mechanism (e.g mutex )
pthread_mutex_lock()
if (!checkdirExist())
createDir()
pthread_mutex_unlock()
movefiletodir().
Your idea sounds pretty good. I just have a few opinion to add.
- Mo Lam May 23, 20131) Well, you have no choice other than looping through them since you have to read all files
2) What if there's a repeated company name