I have watched a few of your videos. I have to say... you explain things well, and you get to the nuts and bolts. Thank you and keep it up! =)
@tungbigbang982 жыл бұрын
Code vault coming in clutch again, thank you!
@oussamasallak94902 жыл бұрын
Great explaination thank you
@andrelemospiucco5364Ай бұрын
So the reason to use trylock is make the waiting threads do something if else if the locked area is used, instead of just wait
@CodeVaultАй бұрын
Exactly
@jackh4158 Жыл бұрын
thanks for the explanation!
@stefanknezevic63622 жыл бұрын
Why is there no warning, for reaches end of non-void function (routine)?
@CodeVault2 жыл бұрын
If you compile with gcc -Wall -o main main.c that warning will appear. Best practice would be to return NULL; in the routine function
@narasarajv52783 жыл бұрын
Thank you for this video, I am watching all your videos. May i know your name please..
@caiomazzaferroadami6 ай бұрын
If I don't care what is executed when I don't get the lock or if I don't want anything to execute when I don't get it, would it be okay to just call trylock and not checking for it's value?
@CodeVault6 ай бұрын
I guess you could... but I am not sure about the use-case of that. Usually you try_lock because you want to do something based on if you got the lock or not. If you do the same for both cases... then why even call try_lock?
@Codality2 жыл бұрын
THX
@js47733 жыл бұрын
when mutex_lock was not successful, it can sleep(schedule for other thread). When mutex_trylock() fails, it does the same thing? What is the main difference when mutex_lock and mutex_trylock failed to get the lock?
@CodeVault3 жыл бұрын
If mutex_lock can't acquire the lock, it has to wait to until it can. If mutex_trylock can't acquire t he lock, it simply returns a status code and continues execution.
@js47733 жыл бұрын
@@CodeVault Thanks a lot for your reply. I maybe confused with spinlock() where it spins when it can't obtain the lock.(so it's used in interrupt context where it can't sleep), and as I know, mutex_lock when it fails it can sleep, so it is used in userspace/process context. However based on your comment, spinlock() and mutex_lock() are same(they wait(spin) until they can acquire lock). Am I understanding it correctly? Thanks!
@CodeVault3 жыл бұрын
Yeah, a spinlock will still wait... but it's just a continuously running loop that checks really really often. It wouldn't be a loop if it didn't wait :D
@js47733 жыл бұрын
@@CodeVault Thanks, it would be great, if you go over pthread spinlock as well and compare the difference between mutex/spinlock. Thanks!
@ShubhamKumar-id9sm3 жыл бұрын
What does errno.h do?
@CodeVault3 жыл бұрын
It's just a header file that has all the error types defined and a few utilities to get the current error: man7.org/linux/man-pages/man3/errno.3.html
@tumblelandproduction3 жыл бұрын
If trylock == 0 that means it was not locked, so it locks itself then enters the critical section?
@CodeVault3 жыл бұрын
Yes, you can read more about this function on the docs page: linux.die.net/man/3/pthread_mutex_trylock
@NoneStopDamage2 жыл бұрын
slow down man god damn
@CodeVault2 жыл бұрын
I think KZbin has a slow down feature. If I go too fast, I'm sorry about that. Although I don't want videos to be unnecessarily long and waste time like many other tutorials on the platform.
@timotheelegros17162 жыл бұрын
@@CodeVault Don't worry about your speed I think its perfect. Easy to understand and concise. I watched in 2x speed and it's just right for me. If @Damage needs to go slower he can use the lower speeds or pause as you mentioned.
@guillaumelacroix4436 Жыл бұрын
also agree, your speed is perfect! Thank you for your videos! @@CodeVault
@AlFredo-sx2yy Жыл бұрын
for me he goes too slow and i have to put him on 1.5x or even 2x sometimes. Thats the good thing about watching a video instead of being in a lecture in person. You can change the speed at which the video plays so you're free to learn at the pace that fits your taste the best.