Reading both answers it appears that both answers provide a solution for creating a mutex but there are some cases where you need to use flock and some where you need to use mkdir:
- if you need already robust/tested features like timeout, blocking, etc etc --> use flock
- builtin timeout 
- builtin support for blocking or nonblocking
- builtin support for deleting the mutex after it is used 
 
- if your distro does not have flock--> you are forced to usemkdir
- if you need any of the timeout or other features provided by flockyou have to reinvent the wheel
- using mkdirfor creating a mutex means your code does not convey the purpose immediately --> whereas usingflockmeans your code speaks for itself saying "this code is implementing synchronization"
- most people aren't familiar with mkdirbeing a valid solution for creating a mutex and so usingmkdirin this way may make your code have more code smell (especially if your distro hasflockavailable and you choose not to use it)