Amazon Interview Question for Software Engineer / Developers


Country: India




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

this is what i think...
threads are useful when they share some variables or address space..thus context switching between them is more efficient as compared to between processes...
thus implementing multiple threads in the given case would prove useful only when the tasks have some variables shared..if they are completely independent of each other..there is no difference between using seperate processes or seperate memory...
also multithreading would be favoured in case of uniprocessor arhitecture while multiprocessing in multiprocessor as already mentioned in the post of Preetam..
correct me if i am wrong.
Thanks.

- Anonymous February 04, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Well, you're right that it should probably depend on whether the data is completely independent or shared across the 3 processes.

I don't know so much about the efficiency difference. I think some OSes implement threads and processes in much the same way. In any case, it's definitely an OS-specific detail.

- eugene.yarovoi February 05, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

I would ask here what's the architecture of the system. If it uses a CPU having multiple cores then I would prefer the separate threads implementation. But if its a single core CPU I would go for a multi-threaded implementation.It is because the thread switch overhead is much less than that of a process switch.

- Preetam February 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Correction - on multiple core it would be multiple process

- Preetam February 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

i told him that if i will use process then at a time i will use one process when it will completed then i will swap with another process.lets assume that if one task is taking 4bytes memory then in this way i will able to complete my task in only 4 bytes. but if i use 3 threads within one process then i have to use 12 bytes . then he told me lets assume you have lot of space.then which you would prefer.

- time February 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hi,
I would choose threads. As they are more efficient. Tasks can be completed in shorter period of time.

- anjum February 04, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

k lets assume if two of them want to access same data at a time. means if you thread A want to access some data D. and thread B want to access data D at that time. then their would be conflict between them.

- time February 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Access for read only or access for writing.

- Anonymous February 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Wouldn't all that be managed by OS. They could have Round Robin or some method for devising that.

- anjum February 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if two threads want to access same data at a time then we will apply semaphores for that.

- uddeshyakumar.kumar February 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The cost of spawning a thread is much cheaper than creating a separate process.
Create a process when you want a part of your system to run independently, such as something that provides a service. You can still communicate with IPC ( inter process communication ). But if you want to speed up your program and sharing some data, address space..use threads.

- SuYo February 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@time : it would be very helpful if u could share more questions f2f [2nd/ 3rd/ 4th ] round also

- Anonymous May 23, 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