McAfee Interview Question for Software Engineer / Developers






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

i am perplexed why such questions are asked but i have gone thru this and here is the researched answer..

First say that what you are telling is about the POSIX semaphores and not the system v semaphore.
and pthread mutex.



a) semaphore is basically a synchronization primitive but mutex is a locking primitive
b) a semaphore can be a mutex but a mutex cannot be a semaphore
c) semaphore can be signalled by any of the thread by using sem_post() but a mutex can be unlocked only by the thread which owns it.
d) semaphores can be used between threads of different processes but mutex work between threads of the same process or between related process.
e) semaphores are system wide and remain in the form of files on the filesystem until cleaned but mutexes are process-wide.


Spinlocks are locks used in the kernel code where we know the code fragment which acquires and releases the lock is deterministic. They continuously poll to know the status of the lock. Busy sleep.

- anon July 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

summarized beautifully :)

- sreenivas December 03, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

good explaination !

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

mutex can be used to synchronize between processes as well and critical section is used to synchronize between threads in a process (CS are lightweight compared to mutex and semaphore and other synchronization mechanism which kernel mode resources)

- mutex September 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

spinlock is used in kernel mode and is blocking or in other words when wait can not be interrupted. In single processor system the thread owning spin lock gets unrestricted access to CPU resource (expect for interrupt of higher priority)
mutex and semaphore are used when wait is interruptible.
Mutex is also a concept meaning synchronization events and timers (dispatcher objects in windows OS) also allow only one thread to become ready.
Fastmutex, kernel mutex and guardmutex are also other synchronization primitives available in windows kernel which implements mutex concept and can be used at different IRQLs depending upon need.

- Anonymous October 04, 2011 | 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