Bloomberg LP Interview Question for Software Engineer / Developers






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

The child process is created with a single thread -- the one that called
fork(). The entire virtual address space of the parent is replicated in
the child, including the states of mutexes, condition variables, and other
pthreads objects; the use of pthread_atfork(3) may be helpful for dealing
with problems that this can cause.

- Hitesh June 21, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Whether the child process contains two threads depends the place where the two threads in the parent are created. If they are created after the creation of the child process, the child process will also have two threads. If we want to make threads safe, we should not protect the global variables in the same process. Is it right?

- chenming831 April 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. When a child process is created using fork, the stack of the calling thread is copied . Other threads is not copied to the child process.
2. For deadlock to occur, cycle is needed. From the Q, it appears that child process acquired the lock on resource(for example, file) of parent process. But it doesn't mention that parent process also acquire on resource of child process.... So, Q not clear..
3. Fork() is not thread safe. There can be side effect if other thread can create side-effect(for example, corruption of global variables, mutex etc).

- deepak June 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What is the exact answer of this question?

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

1.

fork()

duplicates the current process.

exec()

tells a thread to executes another executable.
2. A deadlock can happen if you have the following:
a. Mutual exclusion, which means a resource that only one thread can use a time.
b. Hold & wait - hold a resource while you wait for another.
c. Non-Preemtion - you can't take the lock from another thread.
d. circular waiting - for processes (threads) p1...p_n, p_i is waiting for a resource held by p_(i-1).
So the question should be more clear.
3. If you have 2

fork()

, you'll have 4 threads (unless you exec() after the first

fork()

).
4. The question should be made clearer. In general, if after

fork()

you have, let's say,

printf(<whatever>)

, you can't predict the outcome. You need to use synchronization mechanisms.

- Anonymous April 06, 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