Short introduction to threads (pthreads)

Поделиться
HTML-код
  • Опубликовано: 26 янв 2025

Комментарии • 209

  • @elizabethmessina6322
    @elizabethmessina6322 3 года назад +206

    You've been such an amazing help for my Operating Systems class. Thank you, thank you, thank you

    • @atiedebee1020
      @atiedebee1020 3 года назад +1

      You're coding operating systems... In java?

    • @nonyabizness577
      @nonyabizness577 3 года назад +15

      @@atiedebee1020 im pretty sure she’s coding in c and linux because the video is in c and in a linux env

    • @atiedebee1020
      @atiedebee1020 3 года назад +10

      @@nonyabizness577 I'm confused, as I don't know where I got java from

    • @gorkaurzelai5072
      @gorkaurzelai5072 3 года назад +3

      @@atiedebee1020 hahahahaha

  • @Hundar10TheGreat
    @Hundar10TheGreat 3 года назад +17

    Magnificent presentation, thank you. Other professors make it seem too difficult because they don’t properly address with simple words when programming. They would give the correct definition of pthread_join, but then not clarify that it is basically a wait() function for threads. They were like this all the way through the lessons, so this was tremendous help, thank you.

  • @JakeShuf
    @JakeShuf 2 года назад +31

    I know you get this a lot, but your videos on C are a godsend! You've really helped me and countless others to succeed in our education.

    • @learningalgos614
      @learningalgos614 2 года назад +2

      yeah I watch his videos before working on stupid college projects

  • @ryoma8402
    @ryoma8402 2 года назад +4

    I discovered your channel 3 years ago when I needed help with my "Programming 2" class which involved lists, pipes and processes and couldn't figure out how they work. Now here you are again coming to my rescue perfectly explaining in 8 minutes what my teacher cannot explain in 2 hours. Thanks for preventing me from dropping out of Engineering.

  • @albanec4702
    @albanec4702 Год назад +1

    I can`t find right words to fully express how simple and great this lesson starts thread theme... like u`ve said that I`d heard, read, seen so many times, but in an absolutly clear way and now I`m starting to feel that threads aren`t that scary and wierd - thank u soooo much!👍

  • @rfpixel
    @rfpixel 3 года назад +4

    I've been watching most of your videos about threads. They've been really useful to refresh my concepts that I haven't been using from a long time!!! Thank you so much for the great content you created!!!

  • @oiramormedeiros
    @oiramormedeiros 4 года назад +9

    This is the best channel for C programming! Thank you!

  • @milostadic4215
    @milostadic4215 5 месяцев назад

    I've seen my fair share of youtube tutorials, and I must say yours are top-notch. Thank you for your hard work and for sharing your passion so selflessly. You do make one feel welcome here.

  • @FirstLast-jl1wc
    @FirstLast-jl1wc Год назад

    just took a year off from my degree and completely forgot about how to use P_threads and this basically caught me back up to speed, incredibly good explanation.

  • @nicholas10148
    @nicholas10148 2 года назад +3

    Taking an Operating systems class, and you have been a great help throughout the course!

  • @vaibhavsingh-fu1vg
    @vaibhavsingh-fu1vg Год назад

    Binging your videos like I binged Money Heist!! literal Bella Ciao feeling in my mind for my C rejuvenation!!

  • @ahmedalabadi9490
    @ahmedalabadi9490 3 года назад +1

    i love your videos man learning threads rn is a pain but you make it easier

  • @planetx1823
    @planetx1823 3 года назад +1

    I wish you more subscribers dude...you deserve them all.

  • @onurcanisler
    @onurcanisler 3 года назад +5

    *Thanks to my master, CodeVault, I will pass the operating systems course with an A.*

  • @mahmutkoroglu7072
    @mahmutkoroglu7072 3 года назад +2

    Very clear and straightforward. I am amazed by the quality of the presentation. Thank you !

  • @xiaoliu852
    @xiaoliu852 Год назад

    it's much more clear than my professor, thank you!

  • @Pixailz
    @Pixailz 2 года назад +20

    hello, everytime i got the learn somethings new for a project at 42, you are here with a video. the starting point for philosophers :) Are you a 42 students ? thanks you for all your stuff :)

  • @copingforever6093
    @copingforever6093 2 года назад

    thank you for the series I passed my exam on the second try after watching your videos, our professor didnt explain it well

  • @ericlespiana3193
    @ericlespiana3193 3 месяца назад

    Perfect! Thanks for your job Sir!

  • @alanmenescal9871
    @alanmenescal9871 2 года назад

    Dude u are very good I like your classes, thx for the content It will be such a greate help for me

  • @AdiSings2023
    @AdiSings2023 2 года назад +3

    As a little update: in the "void routine()" function you should add the parameter void *arg so there won't be any errors: void *routine(void *arg){...}

    • @CodeVault
      @CodeVault  2 года назад +3

      Yep, I left that out for the first videos so it doesn't get confusing. You shouldn't get an error unless you're using g++ to compile your project

  • @Denis-hs1gq
    @Denis-hs1gq 3 года назад +3

    saving me bratannnn, spasibo bolshoye

  • @pbmodig
    @pbmodig 3 года назад +1

    Best teacher on the web. WP

  • @SleepinKnight
    @SleepinKnight 3 месяца назад

    Amazing class, this you won't even after paying!

  • @rosehawk2041
    @rosehawk2041 2 года назад

    you are better than most of professors teaching c in china

  • @ytbacc0001
    @ytbacc0001 8 месяцев назад

    Thank you, very clear understanding of code

  • @amanvarshney51217
    @amanvarshney51217 2 года назад

    Thank you sir, your videos are really very helpful for me.

  • @Charky32
    @Charky32 5 месяцев назад

    saved me for my computer system fundamentals exam

  • @VasaMusic438
    @VasaMusic438 3 года назад +1

    Great Lesson !!! Thank you !!

  • @MrDartfire
    @MrDartfire 3 месяца назад

    Спасибо!

    • @CodeVault
      @CodeVault  3 месяца назад +1

      Thank you very much!

    • @MrDartfire
      @MrDartfire 3 месяца назад

      ​@@CodeVault Many thanks for fostering of my transformation from devops to the programmer with understanding low-level(basic I believe) principles!

  • @stack.1
    @stack.1 2 месяца назад

    I think if you're using Cmake the dependent libraries options are automatically set for compile/link

    • @CodeVault
      @CodeVault  2 месяца назад +1

      Just use GCC (or make) for small projects (or maybe even larger ones). You will have less headaches overall

  • @milanstojiljkovic4802
    @milanstojiljkovic4802 Год назад

    Great video! Could you tell us what VSCode extension you are using for function descriptions when you hover over them? Thanks!

    • @CodeVault
      @CodeVault  Год назад

      It's the official C/C++ extension from Microsoft but it doesn't show descriptions on Windows or Mac because the header files don't have them. Those descriptions only exist on Linux it seems

    • @milanstojiljkovic4802
      @milanstojiljkovic4802 Год назад

      @@CodeVault Oh, that's a shame... Thank you very much for your response!

  • @vitorsergio8877
    @vitorsergio8877 2 года назад

    i love you so muccchhhhh codevault

  • @sophiaonyoutube
    @sophiaonyoutube 10 месяцев назад

    amazing teacher. thanks for this!!! :))

  • @frankkevy
    @frankkevy 3 года назад +1

    Your course helped me a lot dude, thank you, thanks a lot

  • @ruby-vn7sz
    @ruby-vn7sz 2 года назад

    thank you so much this really helped me a lot!!!

  • @sergeyrykovanov6396
    @sergeyrykovanov6396 Год назад

    Thanks for tutorial!!! One comment (unless I am wrong): it would make it cleaner to return NULL in all the void* functions

    • @CodeVault
      @CodeVault  Год назад +1

      You're not wrong. It was an oversight and indeed the void* functions should return NULL if nothing else

  • @yuvaye9713
    @yuvaye9713 3 года назад

    is there a package in atom that show function's prototype like vs at @1:29 ?

    • @CodeVault
      @CodeVault  3 года назад

      I'm not familiar with Atom, sorry

  • @ShubhamKumar-id9sm
    @ShubhamKumar-id9sm 4 года назад

    This is only topic that I had to refer to other channels to learn. Now issue resolved

  • @bettyswunghole3310
    @bettyswunghole3310 3 года назад +1

    Great tutorial! Very clear and straightforward.

  • @viniciuss.9250
    @viniciuss.9250 2 года назад

    thank you, thank you, thank you 🚀🚀

  • @junaidamjad5053
    @junaidamjad5053 5 месяцев назад

    How do we know how many cpus are involved in multiple threads? Let say I have 8 cpus and I created 8 thread, how do we make sure that each cpu gets exactly one thread? And even if we are just interested in knowing how these 8 threads are split among 8 cpus, how we could find out this?

    • @CodeVault
      @CodeVault  4 месяца назад +1

      We don't. The scheduler is the one that handles this problem. Although, usually, these high-computing work is assigned to its own CPU core in most schedulers if there's nothing much else going on in the background. Although, again, there is nothing guaranteeing this

  • @newtanagmukhopadhyay4716
    @newtanagmukhopadhyay4716 3 года назад

    i did not understood the use of pthread_join properly. what if we try running this program by commenting the pthread_join?

    • @CodeVault
      @CodeVault  2 года назад +1

      You have to understand that pthread lets you create multiple threads in the same process. So any thread you create are actually running under the same process. If, say, you create 4 threads to do some hard work that takes a while, but, in the main function, right after creating them, you reach the return statement then the process itself terminates and the threads fail to completely finish their work.
      Basically when calling pthread_join for a certain thread, it waits until that thread finishes execution

  • @EdwinFairchild
    @EdwinFairchild 2 года назад

    is it possible to give a thread a timeout, so if my function is not done executing in some time ebcause it is hanging or something, have the thread return

    • @CodeVault
      @CodeVault  2 года назад

      Yes, there is the function pthread_kill ( man7.org/linux/man-pages/man3/pthread_kill.3.html )
      You could create another thread that waits for a while and pthread_kills the thread you want to timeout

  • @hell0vv0rld
    @hell0vv0rld 2 года назад

    Great explanation! thanks very much

  • @animeshkumarsinha5954
    @animeshkumarsinha5954 Год назад

    Is there any difference between posix threads & thread from std namespace?
    Like performance or user friendly?
    How to decide which one to use and when ?

    • @CodeVault
      @CodeVault  Год назад

      pthreads (posix threads) are Unix-specific (available in C/C++) and std::thread is part of the C++ standard library. Both are just interfaces for working with (usually) the same entities under the hood. So, aside from the interface overhead, there shouldn't be any differences really

  • @mehdibenhariz3281
    @mehdibenhariz3281 2 года назад

    you are a life saver

  • @Ricko65
    @Ricko65 2 года назад

    Great tutorial - thank you very much!

  • @spurthidantu6890
    @spurthidantu6890 2 года назад

    How do i prevent memory leaks in Pthreads? The first time i execute the program, answer is right but if i add a while loop, it is providing incorrect values.Even after adding pthread_join, same thing is happening.

    • @CodeVault
      @CodeVault  2 года назад

      Can you share the code? I can't exactly tell what you're doing wrong

  • @yacinoskhey1626
    @yacinoskhey1626 3 месяца назад

    Nice video. I still didn't get the last part with the if statement. Why that?

    • @CodeVault
      @CodeVault  3 месяца назад +1

      Basically it's to check if the pthread_join was successful. Of course, in real-world projects you would handle the errors differently, not just return an error code probably.

    • @yacinoskhey1626
      @yacinoskhey1626 3 месяца назад

      @@CodeVault Got it. Thank you so much.

  • @atTran-xv5iz
    @atTran-xv5iz Год назад

    This is helpfull, thank you I will watch it all. I have have a question, I'm learning Go it has routine, does it similar to thread in c? (because Go was build base on C, I believe)

    • @CodeVault
      @CodeVault  Год назад

      I am not familiar with Go, sorry

  • @sakkamouid3343
    @sakkamouid3343 2 года назад

    I saw in a tutorial comparision between user level threads and kernel level threads that Multithreading isn't possible in user level threads. First , I would like to make sure and classify the threads that we are creating here . They are probably user level Threads because according to their definition they are created by the user just like we did here. But the thing that I don't understand is , how multithreading not possible user level Threads? Isn't that we did in our case executing two threads end getting same output twice called multithreading?

    • @CodeVault
      @CodeVault  2 года назад +1

      I researched for a while to find an answer and, for these specific videos running pthread on this specific OS (Linux) we are mapping each user-level thread created using pthread_create to a kernel-level thread. So you could say we are using kernel-level threads in this video. But all this is dependent on the underlying operating system and their implementation of pthread.
      Here is a clear answer (and more details to your question if you are interested in reading more about it): stackoverflow.com/a/53958312

  • @ismailcemtuzun9221
    @ismailcemtuzun9221 2 года назад

    Amazing teaching !

  • @B18-a
    @B18-a 7 месяцев назад +16

    If you are here from 42 👍😉

    • @shenghongzhong
      @shenghongzhong 7 месяцев назад

      What project were you doing and which circle?

    • @B18-a
      @B18-a 7 месяцев назад

      ​@@shenghongzhong I finished minishell and now I do philosophers in circle 3 and you

    • @woodenmonkeyfox
      @woodenmonkeyfox 6 месяцев назад

      Yes, for push_swap. I want to have realtime visuals of the stacks for fun.

  • @arslanbegmyradov3048
    @arslanbegmyradov3048 3 года назад +1

    how to setup pthread.h library under vs code? Please help me.

    • @CodeVault
      @CodeVault  3 года назад

      As I said in the video, just add -pthread to the gcc command. In VSCode that should be adding in tasks.json under the args array.

  • @dherendrasingh4761
    @dherendrasingh4761 Год назад

    Hi Sir,
    could you please tell again how this if condition make safer our code and didn't understand this condition "!=0 " . Please reply anyone.

    • @CodeVault
      @CodeVault  Год назад

      If pthread_create returns 0 that means it was successful. If it returns anything else, we exit the program because something wrong happened with creating a thread

  • @sebiuo5817
    @sebiuo5817 4 года назад

    Thaks! you are the "Julio Profe" for C

  • @Jin-ec1vc
    @Jin-ec1vc 2 года назад

    nice and clear explanation!

  • @varunsriram8987
    @varunsriram8987 4 месяца назад

    why the parameters in the main function? can someone help?

    • @CodeVault
      @CodeVault  4 месяца назад

      It's just the standard. There is this video explaining what they are exactly: code-vault.net/lesson/dbijqbwu2a:1603733526118

  • @ruok1992
    @ruok1992 2 года назад

    what is the API you talked about ? I've been searching in Google - can you help me with it ?

    • @CodeVault
      @CodeVault  2 года назад

      Ohh, I was just talking about the pthread API there: man7.org/linux/man-pages/man7/pthreads.7.html

  • @chaimaeelhaimer870
    @chaimaeelhaimer870 3 года назад

    your video was very helpfull to me
    thank you !!

  • @sakkamouid3343
    @sakkamouid3343 2 года назад

    What I have understood about the function pthread_join() is that , it waits until the thread passed in its first argument is terminated. That logically means that removing the call of this function doesn't stop the thread from executing, because that's the job of the pthread_create() function . But when I tried so and removed the call of the pthread_join() function I didn't get an output, which means the thread t1 didn't execute. Why?

    • @sakkamouid3343
      @sakkamouid3343 2 года назад +1

      I Think I have just found the answer. The function pthread_join() 's job is to make the calling thread wait until the created thread finishes execution. Here main() represents the calling thread. In case of removing the pthread_join() the main thread will finish exection throught return 0 and the program ends before the execution of the thread t1. That's why I had no output.

    • @CodeVault
      @CodeVault  2 года назад +1

      That's correct. This is different from processes where they can still execute on their own even if the parent process stopped executing. Threads simply terminate execution when the process that created them

  • @ericz7881
    @ericz7881 2 года назад

    Great video thanks. Can you please help explain why you only wrote if statement in pthread_create and pthread_join, but no else statement? I understand if pthread_create doesn't return 0 then it's an error, but I'd think there needs to be an else statement to tell the program what to do when there is no error.

    • @CodeVault
      @CodeVault  2 года назад +2

      When there is no error it just simply continues its execution like expected.
      if (a == b) {
      return;
      }
      printf("a doesn't equal b
      ");
      Basically, in this code above, because we have a return statement in the if block, the code below only executes if the statement a == b is false (if it was true it would've returned out of the function and never execute anything below it)

    • @ericz7881
      @ericz7881 2 года назад

      @@CodeVault Thanks, I understand what you are saying, but, your code is more like -
      int main(int argc, char* argv[]{
      int a;
      if(a != 0){
      printf("Error");
      }
      return 0;
      }
      If my understanding is correct, when a==0 is true, the program will just simply run to the end without printing anything.

  • @marcinziajkowski3870
    @marcinziajkowski3870 2 года назад +3

    3:00 Why do you need ampersant "&" ? Function name without brackets is already returning the address of the function.
    This is equal:
    &function_name == function_name

    • @CodeVault
      @CodeVault  2 года назад +5

      Both ways seem to be accepted by the standard. I just thought it was easier to understand with the ampersand. Without the ampersand it's technically an implicit cast from function type to pointer to function type

    • @marcinziajkowski3870
      @marcinziajkowski3870 2 года назад +1

      @@CodeVault Thank you for a fast answer.

  • @nicholas10148
    @nicholas10148 2 года назад

    How do you get VS code to show the pop up with the different arguments, for things such as pthread_create?

    • @CodeVault
      @CodeVault  2 года назад

      It should by default do that if you have the C/C++ extension installed

  • @mayelinespino2487
    @mayelinespino2487 2 года назад

    Good morning. Do you have a video explaining function that return void *?

    • @CodeVault
      @CodeVault  2 года назад

      There's a video explaining what void* is: code-vault.net/lesson/qon6f2tjor:1603733520405
      Those functions return exactly that data type

    • @mayelinespino2487
      @mayelinespino2487 2 года назад

      @@CodeVault Thank you so much! I will check it out.

  • @KokoMbella
    @KokoMbella 2 года назад

    Hi, I am using Ubuntu 20.04.4 LTS. On VSCode I can't include the header , only works. I can locate pthread.h in /usr/include/pthread.h. How do I include the header in VSCode?

    • @KokoMbella
      @KokoMbella 2 года назад

      I found the problem. In tasks.json I changed "command": "/usr/bin/g++" to "command": "g++".

  • @georgesheng6046
    @georgesheng6046 2 года назад +1

    can you please make a video about sockets? my final exam is coming up and I have no idea how they work !!

    • @aparna-rajesh
      @aparna-rajesh 2 года назад

      oh my goodness, me too!

    • @ShaunYCheng
      @ShaunYCheng 2 года назад

      I am not in school but would love to learn about sockets using C

  • @pulkitjoshi2963
    @pulkitjoshi2963 3 года назад

    how to use user defined signals with threads ? More specifically i want to signal a thread and pause that thread

    • @CodeVault
      @CodeVault  3 года назад

      You can't do that with threads since they run on the same process. Signals are used to communicate between processes, not threads. If you want to synchronize threads just use any of the tools we discussed in the course: semaphore, condition variables, mutexes etc.

    • @pulkitjoshi2963
      @pulkitjoshi2963 3 года назад

      @@CodeVault pthread_kill ? for Posix thread seem to work. What is problem with that?

    • @CodeVault
      @CodeVault  3 года назад

      That simply controls which thread executes the handler for those signals. Certain signals might be process-wide. See: man7.org/linux/man-pages/man3/pthread_kill.3.html (in the Notes section)

  • @MuhammadAli-ve7mt
    @MuhammadAli-ve7mt 2 года назад

    I've tried adding pthread in tasks.json but it just doesn't seem to work when I run the program using vscode.
    It works through the terminal but not vscode. It still gives the undefined reference error. Is anyone able to help?

    • @CodeVault
      @CodeVault  2 года назад

      Double check you're running the correct build task, also, how did you compile it in the terminal when it worked? Are you trying this on Windows?

    • @MuhammadAli-ve7mt
      @MuhammadAli-ve7mt 2 года назад

      ​@@CodeVault I'm using ubuntu 20.04. I compiled the file using a buildtask where I included '-pthreads' and when I execute the code by typing './threads' in the vscode terminal, it works properly but it doesn't work when I press the run code button or through the keyboard shortcut ctrl+alt+n
      This might be tedious but I can't seem to figure out the problem

    • @MuhammadAli-ve7mt
      @MuhammadAli-ve7mt 2 года назад

      @@CodeVault is it possible that it might not be using the build task I created when I press the run code button or use the shortcut?

    • @CodeVault
      @CodeVault  2 года назад

      Make sure that in launch.json, the preLaunchTask matches the name of the compilation task in tasks.json exactly

  • @digitallova
    @digitallova 2 года назад

    How to print process Id and thread id knowing that threads are executing within the same process

    • @CodeVault
      @CodeVault  2 года назад +1

      I talk about getting the thread id in this video: code-vault.net/course/6q6s9eerd0:1609007479575/lesson/18ec1942c2da46840693efe9b5210e1b

  • @milequinze
    @milequinze 2 года назад

    Many thanks!

  • @koltongagnon2799
    @koltongagnon2799 3 года назад

    Could `perror` be used to print an error message on why a `pthread_create` or `pthread_join` failed?

    • @CodeVault
      @CodeVault  3 года назад

      Of course!
      I like using fprintf(stderr, "format string", ...);
      Since it allows for format strings and parameters

  • @anatraversi7060
    @anatraversi7060 3 года назад

    Thank you very much! You saved me in my OS class!!!!!!

  • @Brad_Script
    @Brad_Script 7 месяцев назад

    you don't actually need to pass a pointer to a function, just the function name should be enough. At least in c99.

  • @soumikpattanayak3225
    @soumikpattanayak3225 2 года назад +1

    Idk why but when I'm using sleep()
    It is not stopping there :(
    Plz help

    • @CodeVault
      @CodeVault  2 года назад

      From the documentation, you need to pass in the number of seconds you want to wait for
      www.man7.org/linux/man-pages/man3/sleep.3.html

    • @soumikpattanayak3225
      @soumikpattanayak3225 2 года назад

      @@CodeVault I'm passing a number like sleep(3) after printf("something")
      Then again printf("something") but instead of waiting in the middle it waits at the start for 5 seconds and prints both at the same time

    • @CodeVault
      @CodeVault  2 года назад

      Make sure you add a
      at the end of the string you are trying to print to flush the buffer

    • @soumikpattanayak3225
      @soumikpattanayak3225 2 года назад

      @@CodeVault yes sir now its working
      Thank you very much 🙏🙏

  • @youneshaddad7390
    @youneshaddad7390 2 года назад

    Thank you!

  • @anzu8698
    @anzu8698 3 года назад

    Thank you so much!

  • @nickst2797
    @nickst2797 2 года назад

    Thank you! But is this only for Linux? Does it work in Windows as well?

    • @CodeVault
      @CodeVault  2 года назад +1

      No, it's using the pthread library which is only available natively on Unix systems. You could install WSL on Windows and run Linux under Windows that way.

  • @Sof_net
    @Sof_net 3 года назад

    Hi, first of all THANK YOU for all the great and clear videos, you should definitely be looking for a teaching career. I would like to ask you the link of the settings for the json files. I can't find it anywhere. I looked in the "Unix processes" playlist but they are different. Thank you in advance.

    • @CodeVault
      @CodeVault  3 года назад

      Here's the video related to setting up vscode: code-vault.net/lesson/ublnbln8uf:1603733528013

    • @Sof_net
      @Sof_net 3 года назад

      @@CodeVault You are just amazing!

  • @vladimir_khlghatyan
    @vladimir_khlghatyan 2 года назад

    How can I join to your Discord server?

    • @CodeVault
      @CodeVault  2 года назад

      At this link: discord.code-vault.net/

  • @fakharaltaf1307
    @fakharaltaf1307 Месяц назад

    what code edtor is he using

    • @CodeVault
      @CodeVault  15 дней назад

      It's a version of VSCode. Nowadays I am using Vim

  • @freddy_hd_7073
    @freddy_hd_7073 2 года назад

    sorry, why the function has a pointer?

    • @CodeVault
      @CodeVault  2 года назад

      It's the return type, a void pointer (void*). Here's a video on the topic: code-vault.net/lesson/qon6f2tjor:1603733520405

  • @joycemacksuele8074
    @joycemacksuele8074 3 года назад

    You are very good at explaining things... Congrats :)

  • @PushpendraKumar-it4wf
    @PushpendraKumar-it4wf 3 года назад

    Why the name is pthread_join whereas it is waiting for execution of the thread?

    • @CodeVault
      @CodeVault  3 года назад

      I actually have no idea. Now that you point it out it does seem counter-intuitive to call it pthread_join and not something like pthread_wait

  • @pirithoven_tech
    @pirithoven_tech 3 года назад

    what compiler are using , and what version?

  • @ahmetkarakartal9563
    @ahmetkarakartal9563 Год назад

    thank you so much

  • @nauth1002
    @nauth1002 4 года назад +2

    Great video!
    Can you please make a video on pthread conditions and Semaphores in C (Synchronization).
    Thank you again.

    • @CodeVault
      @CodeVault  4 года назад +1

      Yes, expect to see videos on these topics too

  • @Toccobass13
    @Toccobass13 2 года назад

    thank you so much

  • @talroz8431
    @talroz8431 4 года назад

    Is threads important for cyber security in C?

    • @CodeVault
      @CodeVault  4 года назад +1

      I guess so. If the software you're trying to secure uses threads, race conditions and other issues of the like are really nasty vulnerabilities

  • @Fahodinho
    @Fahodinho 2 года назад

    where are you from?

  • @gagangayari5981
    @gagangayari5981 3 года назад

    Why is my parallel version slower than the serial version ? .Did anybody face this issue ?

    • @CodeVault
      @CodeVault  3 года назад

      If your critical section is the majority of the code executed by each thread, the serialized version might be better (since it doesn't have to do all the locks and unlocks).

  • @ze3r498
    @ze3r498 4 года назад

    Great Video, love to study with your videos. :)

  • @muhammadzaeemnasir290
    @muhammadzaeemnasir290 3 года назад

    Amazing 🤩

  • @amirahmedhassan6087
    @amirahmedhassan6087 Год назад

    Hello
    I'd like to report that the code did not work with me but I had to edit on the function declaration
    void* routine(void* n)
    {
    }
    This worked fine with the pthread_create

    • @CodeVault
      @CodeVault  Год назад

      Yes, the function signature was a bit wrong. My bad

  • @adiii_pramanik
    @adiii_pramanik 3 года назад

    Thank you so much for this beautiful explanation,
    I have a doubt pthread_join() is not exiting itself in my machine.
    Is it compiler configuration which is letting this happen or is it something else?

    • @CodeVault
      @CodeVault  3 года назад +1

      What do you mean by "exiting itself"?

    • @adiii_pramanik
      @adiii_pramanik 3 года назад

      @@CodeVault my main function is not ending it's stuck in infinite loop I think

  • @suneelabbigari
    @suneelabbigari 3 года назад

    Great series.

  • @maltesetoy3653
    @maltesetoy3653 3 года назад

    Thank you! It really helped me

  • @shakhriyortoylokov3394
    @shakhriyortoylokov3394 4 года назад

    Sir thank you for your efforts. Your teaching method is very understandable. So, can you make videos example codes on how or what kind of situations this topics e.g. threads is used . I mean the videos about really life examples in software industries and how to code them with some example codes

    • @CodeVault
      @CodeVault  4 года назад

      Yes, of course. Real life examples are always good when learning a new topic, although I'm not going to show anything too complex

  • @amparecircuit2405
    @amparecircuit2405 3 года назад

    Sir please batao
    Sigsegv thread -1.794849282
    Kya matlab hai iska
    In c programming

    • @CodeVault
      @CodeVault  3 года назад

      What is causing that?

    • @amparecircuit2405
      @amparecircuit2405 3 года назад

      @@CodeVault sir mera pc nhi hai 'mobile c' android app par
      scanf function and printf function use kar ke two numbers add karne ka program likha tha
      Jab me number type kar ke enter daba tha hu toh
      Sigsegv thread -1.79484982 dikha tha hai

    • @CodeVault
      @CodeVault  3 года назад

      Sorry... I don't understand. Can you comment in English please?

    • @amparecircuit2405
      @amparecircuit2405 3 года назад

      @@CodeVault sir i don't have pc
      I write a program on Android compiler
      include
      #include
      int main()
      {
      int a,b;
      printf("enter a =
      ");
      scanf("%d",@a);
      printf("enter b =
      ");
      scanf("%d",@b);
      printf("%d+%d=%d",a,b,a+b);
      }
      When i enter the number The compiler says
      Sigsegv thread -1.7948498

    • @CodeVault
      @CodeVault  3 года назад

      Hmmm. Works fine for me. You don't need #include and I assume you use &a and &b and NOT @a and @b (those are syntax errors)