Reputation: 39
Linux kernel semaphore's down() function comment say
/**
Use of this function is deprecated, please use down_interruptible()
or down_killable() instead.
**/
Someone please explain it, best wish to you.
Upvotes: 2
Views: 1755
Reputation: 2517
It is explained in comments for down_interruptible and down_killable
TLDR; down doesn't allow you to interrupt when it is sleeping i.e. didn't got semaphore. where as these two exits with -EINR so responsive code.
understand the use of this function down() Acquires the semaphore. If no more tasks are allowed to acquire the semaphore, calling this function will put the task to sleep until the semaphore is released. that means it will not be interrupted if calling process got interrupted. or killed. underlying logic differs in second argument to _down_common()
So it is suggested to use any of two suggestion so that it can be processed in case of interrupt. Also no use of keeping it after calling process got killed.
Major thing deprecated function is more likely to be discontinued in future. in this case it hasn't as it is available still in 4.16 which is latest kernel while writing this.
Upvotes: 1