Multithreading | Lock Free Programming | HFT Quant Interview

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 พ.ย. 2024

ความคิดเห็น • 19

  • @CodingInterviewPrep
    @CodingInterviewPrep  ปีที่แล้ว +4

    ignore the sound of AC in background. Didn’t realise that it was so loud. Apologies 🙏

    • @kushgh
      @kushgh ปีที่แล้ว

      The AC noise is not an issue, Great Content!
      Just one question - Why write lock-free programs? What is the use case here?

  • @TheJocadasa
    @TheJocadasa ปีที่แล้ว +7

    Doesn't using std::atomic to synchronize like this resemble a spinlock? Can that trully be called lock-free?
    With a large number of threads, the likelihood of the running thread being the correct one is low. So wouldn't it be more prudent to use blocking primitives like semaphores/condition variables?
    On another note, since we continuously spin and will eventually read the updated value, can't we use a non-thread-safe integer instead of std::atomic in this scenario?

    • @abhi-5783
      @abhi-5783 6 หลายเดือนก่อน

      No, using std atomic ensure sequential consistency, which ensures that the compiler doesn’t do reordering or read old cached value.

    • @TheJocadasa
      @TheJocadasa 6 หลายเดือนก่อน +1

      ​@@abhi-5783 I understand now that we can't use a non-thread-safe integer because of UB. The memory ordering also ensures the proper value of `currIndex` is read.
      However, I still don't understand how this "lock-free" approach makes any sense in this scenario. Especially if we are expecting a large number of threads, or we are doing slow operations like writing to and flushing std::cout. Isn't this just a bad use-case for atomics?

  • @sarathiprabu
    @sarathiprabu ปีที่แล้ว +1

    Thank you. Your approach and code is clean and elegant. Please create similar videos like this whenever you get time...

  • @akshatsharma9527
    @akshatsharma9527 ปีที่แล้ว +1

    Shubham I always enjoy your videos quite informative being a SDE still lots of Things i have to learn concurrency ,,, Great

  • @eddanapudir
    @eddanapudir ปีที่แล้ว

    This is very useful. Thank you very much. May I request you to post a video on ‘how market data handlers work and update order book in HFT firms’ please? Thanks

  • @nachiketkanore
    @nachiketkanore ปีที่แล้ว +1

    I don't understand why multithreading is relevant for this problem. Only one thread is doing work at a particular time, while others are waiting for their turn. For learning purposes, it is fine but it would be better if a real use case is chosen.

    • @CodingInterviewPrep
      @CodingInterviewPrep  ปีที่แล้ว +2

      these kind of questions are asked to check if a candidate knows about thread synchronization and is able to implement it. These concepts are very useful in systems which utilises the pipeline architecture for very high throughout, where the output of nth thread is input to (n+1)th thread.

  • @nishankverma7655
    @nishankverma7655 4 หลายเดือนก่อน

    I've a question is it ok to use global variables while using this programming techniques

  • @PHANTOMWORLD
    @PHANTOMWORLD ปีที่แล้ว

    yes please post videos regularly

  • @raunaquepatra3966
    @raunaquepatra3966 3 หลายเดือนก่อน

    the while loop is technically a lock

  • @abh9789
    @abh9789 ปีที่แล้ว +2

    Bhaiya, I would be highly grateful if you can kindly advise that, in your genuine experience, do ranks on competitive programming profiles help in getting shortlisted for interview?? Even as Candidate Master in Codeforces or 6* in CC... I'm nit grad this year, but asking in respect of off campus & not particularly for hfts. Thanks bhaiya immensely!🙏🙏

    • @liquidmetal718
      @liquidmetal718 ปีที่แล้ว

      Unless you prove yourself in those coding rounds or hackathons - conducted by companies, no one would care about your ranks. This is not like JEE Advanced exams, where people get selected based on ranks.

  • @Tech_Deviser
    @Tech_Deviser ปีที่แล้ว

    Bhai what would be chances of getting selected in hft for CP vs Non CP but good skills