Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Threading Interview Question

Threading Interview Question

Scheduled Pinned Locked Moved C / C++ / MFC
javascriptalgorithmsbusinesshelpquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nawal K Gupta
    wrote on last edited by
    #1

    Problem 2: Threading: Requirements: In a particular system there are two threads T1 and T2. T1 is the master thread that periodically sends messages to the worker thread T2. The system is time-critical and hence T2 must react to every message that T1 sends. None of the messages must be lost.T2 performs time consuming operations like say mixing sound samples and sending them to the sound buffer. Here is the hypothetical POSIX like library that is available to synchronize the threads: Mutex locking and unlocking are done through to the calls int lock(Mutex_t* mutex); int unlock(Mutex_t* mutex); Thread messaging is done through condition variables that operate with an associated mutex. A thread that responds to a message needs to wait on a condition variable. It should own the associated mutex prior to entering the wait state. When it enters the wait state, it simultaneously releases the ownership of the mutex. Upon return from the wait state, it owns the mutex. int wait(Condition_t* condition, Mutex_t* mutex); A thread that sends message to another thread needs to signal the condition variable. In order to signal the condition variable, the thread must own the associated mutex.If no thread is waiting on the condition variable, the `signal' or message is lost. If a thread is waiting on the condition variable, then it resumes execution. int signal(Condition_t* condition, Mutex_t* mutex); Task: You can write this in pseudo code. The idea is to come up with the best and efficient algorithm that would address the requirements. Search Not Complete

    C Z C N 4 Replies Last reply
    0
    • N Nawal K Gupta

      Problem 2: Threading: Requirements: In a particular system there are two threads T1 and T2. T1 is the master thread that periodically sends messages to the worker thread T2. The system is time-critical and hence T2 must react to every message that T1 sends. None of the messages must be lost.T2 performs time consuming operations like say mixing sound samples and sending them to the sound buffer. Here is the hypothetical POSIX like library that is available to synchronize the threads: Mutex locking and unlocking are done through to the calls int lock(Mutex_t* mutex); int unlock(Mutex_t* mutex); Thread messaging is done through condition variables that operate with an associated mutex. A thread that responds to a message needs to wait on a condition variable. It should own the associated mutex prior to entering the wait state. When it enters the wait state, it simultaneously releases the ownership of the mutex. Upon return from the wait state, it owns the mutex. int wait(Condition_t* condition, Mutex_t* mutex); A thread that sends message to another thread needs to signal the condition variable. In order to signal the condition variable, the thread must own the associated mutex.If no thread is waiting on the condition variable, the `signal' or message is lost. If a thread is waiting on the condition variable, then it resumes execution. int signal(Condition_t* condition, Mutex_t* mutex); Task: You can write this in pseudo code. The idea is to come up with the best and efficient algorithm that would address the requirements. Search Not Complete

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      are you asking people to answer your interview questions for you ?

      image processing | blogging

      N 1 Reply Last reply
      0
      • N Nawal K Gupta

        Problem 2: Threading: Requirements: In a particular system there are two threads T1 and T2. T1 is the master thread that periodically sends messages to the worker thread T2. The system is time-critical and hence T2 must react to every message that T1 sends. None of the messages must be lost.T2 performs time consuming operations like say mixing sound samples and sending them to the sound buffer. Here is the hypothetical POSIX like library that is available to synchronize the threads: Mutex locking and unlocking are done through to the calls int lock(Mutex_t* mutex); int unlock(Mutex_t* mutex); Thread messaging is done through condition variables that operate with an associated mutex. A thread that responds to a message needs to wait on a condition variable. It should own the associated mutex prior to entering the wait state. When it enters the wait state, it simultaneously releases the ownership of the mutex. Upon return from the wait state, it owns the mutex. int wait(Condition_t* condition, Mutex_t* mutex); A thread that sends message to another thread needs to signal the condition variable. In order to signal the condition variable, the thread must own the associated mutex.If no thread is waiting on the condition variable, the `signal' or message is lost. If a thread is waiting on the condition variable, then it resumes execution. int signal(Condition_t* condition, Mutex_t* mutex); Task: You can write this in pseudo code. The idea is to come up with the best and efficient algorithm that would address the requirements. Search Not Complete

        Z Offline
        Z Offline
        Zac Howland
        wrote on last edited by
        #3

        Since you don't have the answer, I take it that you are interviewing for a position ... in which case, answering the question for you does no good for either you nor the company you are applying to work for. Pick up an Intro to Multithreading book, or at the very least try to come up with a solution yourself before asking for help.

        If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

        1 Reply Last reply
        0
        • N Nawal K Gupta

          Problem 2: Threading: Requirements: In a particular system there are two threads T1 and T2. T1 is the master thread that periodically sends messages to the worker thread T2. The system is time-critical and hence T2 must react to every message that T1 sends. None of the messages must be lost.T2 performs time consuming operations like say mixing sound samples and sending them to the sound buffer. Here is the hypothetical POSIX like library that is available to synchronize the threads: Mutex locking and unlocking are done through to the calls int lock(Mutex_t* mutex); int unlock(Mutex_t* mutex); Thread messaging is done through condition variables that operate with an associated mutex. A thread that responds to a message needs to wait on a condition variable. It should own the associated mutex prior to entering the wait state. When it enters the wait state, it simultaneously releases the ownership of the mutex. Upon return from the wait state, it owns the mutex. int wait(Condition_t* condition, Mutex_t* mutex); A thread that sends message to another thread needs to signal the condition variable. In order to signal the condition variable, the thread must own the associated mutex.If no thread is waiting on the condition variable, the `signal' or message is lost. If a thread is waiting on the condition variable, then it resumes execution. int signal(Condition_t* condition, Mutex_t* mutex); Task: You can write this in pseudo code. The idea is to come up with the best and efficient algorithm that would address the requirements. Search Not Complete

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          If you would have done your homeworks yourself when you were at school, you would be able to answer the interview questions :rolleyes:


          Cédric Moonen Software developer
          Charting control [Updated - v1.1]

          T 1 Reply Last reply
          0
          • C Cedric Moonen

            If you would have done your homeworks yourself when you were at school, you would be able to answer the interview questions :rolleyes:


            Cédric Moonen Software developer
            Charting control [Updated - v1.1]

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #5

            Cedric Moonen wrote:

            If you would have done your homeworks yourself when you were at school, you would be able to answer the interview questions

            1 point ! :)

            Cedric Moonen wrote:

            Charting control [Updated - v1.1]

            hum hummm :cool:


            TOXCCT >>> GEII power

            [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

            1 Reply Last reply
            0
            • C Chris Losinger

              are you asking people to answer your interview questions for you ?

              image processing | blogging

              N Offline
              N Offline
              Nawal K Gupta
              wrote on last edited by
              #6

              This is not my interview questions. I saw this question somewhere and I wanted to increase my Academic knowledge.

              1 Reply Last reply
              0
              • N Nawal K Gupta

                Problem 2: Threading: Requirements: In a particular system there are two threads T1 and T2. T1 is the master thread that periodically sends messages to the worker thread T2. The system is time-critical and hence T2 must react to every message that T1 sends. None of the messages must be lost.T2 performs time consuming operations like say mixing sound samples and sending them to the sound buffer. Here is the hypothetical POSIX like library that is available to synchronize the threads: Mutex locking and unlocking are done through to the calls int lock(Mutex_t* mutex); int unlock(Mutex_t* mutex); Thread messaging is done through condition variables that operate with an associated mutex. A thread that responds to a message needs to wait on a condition variable. It should own the associated mutex prior to entering the wait state. When it enters the wait state, it simultaneously releases the ownership of the mutex. Upon return from the wait state, it owns the mutex. int wait(Condition_t* condition, Mutex_t* mutex); A thread that sends message to another thread needs to signal the condition variable. In order to signal the condition variable, the thread must own the associated mutex.If no thread is waiting on the condition variable, the `signal' or message is lost. If a thread is waiting on the condition variable, then it resumes execution. int signal(Condition_t* condition, Mutex_t* mutex); Task: You can write this in pseudo code. The idea is to come up with the best and efficient algorithm that would address the requirements. Search Not Complete

                N Offline
                N Offline
                Nawal K Gupta
                wrote on last edited by
                #7

                This is not my interview questions. I saw this question somewhere and I wanted to increase my Academic knowledge. Noting related to homework.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups