Qualcomm Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
6
of 6 vote

First of all, What is the difference between mutex & semaphore.
Binary semaphore is also called MUTEX as per their values but their purposes are different..
Semaphore is used for signalling purpose. A thread waiting for a semaphore might be signalled by the other thread.
Mutex is used for Blocking purpose.
Mutex is used to provide synchronization on same block of code.
An ownership kind of thing is attached with a MUTEX. The lock is released by the object which has acquired it.
While semaphore is used to control the access to finite number of resources.

Since, here is only queue,
Hence, i feel that MUTEX would be a better choice.

- Aashish July 23, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think two of the readers (including shondik) didn't read the question, which states to _avoid_ mutual exclusion...

So -1.

- Anonymous July 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Of course, asking for IPC _to_ avoid mutual exclusion is a nonsense...

- Anonymous July 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Sorry, very true.. Was in a hurry & missed the point.
Does it make any sense to ask for avoiding mutual exclusion when there is only one resource?

- Aashish July 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think OP made a typo and intended to say provide mutual exclusion, rather than avoid...

- Anonymous July 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

As the question clearly states "one or many process try to access the queue"?

This support can be provided by Semaphore as it allows multiple process to enter and read the contents. And we can use "Mutex" which is kind of binary semaphore for writing.
Once the "Semaphore" count is zero one of the process can claim the "mutex" and write.

Another question arises of "concurrency" which can be handled different ways check out linux RCU (Read-Copy-Update) on similar lines.

- redkrzy April 04, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Mutex can be modelled using a binary Semaphore.

So this question is pointless.

- Anonymous July 23, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I would prefer other contending process to sleep, and hence I will use a semaphore.

- Subash Patel August 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Semaphore. Because Mutex can only be used among threads. Semaphores are for inter-process communication

- Raymond September 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 3 vote

Semaphore

- Anonymous July 23, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

When multiple processes are accessong a shared data, then, semaphore is the best way.because mutex has a ownership attached to it and a process taking the ownership of lock can only release it.

- sandeep August 05, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More