Adobe Interview Question for Software Engineer / Developers






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

/* Use test&set */
boolean test_and_set(boolean &mutex) {
  boolean tmp=mutex;   mutex=true;
  return tmp;
}
void mutex_init(boolean &mutex) { mutex=false;}
void mutex_lock(boolean &mutex) { while(test_and_set(mutex));}
void mutex_unlock(boolean &mutex) {mutex=false;}

/* Use swap&test */
boolean swap_and_test(boolean &a, boolean &b) {
   boolean tmp=a; a=b; b=tmp;
   return a;
}

void mutex_init(boolean &mutex) {mutex=false;}
void mutex_lock(boolean &mutex) {
    boolean wait=true;
    while(swap_and_test(&wait, &mutex)) {mutex=true;}
}
void mutex_unlock(boolean &mutex) {mutex=false;}

- jzhu May 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

in Java:

Synchronized function or block would be an example of a mutex.

- sushbis August 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Not an example, I said 'implement' mutex.

- Anonymous September 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The basic constructs of mutual exclusion are usually provided by hardware instructions. Operating system use these and provide types like mutex and condition variables.
Higher level mutual exclusion constructs are built on top of these.

- AmitG November 10, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

your HW has to support an atomic read-modify-write instruction. Then u can implement a mutex. Other way around you has to be able to disable all the interrupts. Either way will work for you . The implementation itself is quite trivial.

- kykydyk March 17, 2013 | 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