Google Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

What is a process: program in execution.
What is a stack: space use to hold the value of the temp variables and keep track of the flow control.
How many stacks can a process have:one (in most of the cases)
What is a thread: its can be think as a unit of CPU execution.
How many threads can a process have:depend on the size of the thread pool and OS
Do the threads have their own stacks, or share the process : threads have their own stack and registers but share the address space with the parent process.

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

So by your own logic then, the best answer to "How many stacks can a process have" would be something like "as many as it has threads".

- eugene.yarovoi April 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

When you say a stack here, i guess you mean the operating system's stack which keeps track of the calls made among processes and co-ordinates them.
But a Process Control Block doesnt contain a stack dedicated to the process, does it? Can anybody clarify this plz.

- TheMitraBoy April 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Stack here is probably referring to the process's stack (in user space), though it does not specifically state it. Each process has it's own kernel stack as well in kernel space for system calls. Lastly, if a process is using kernel threads (1 user : 1 kernel), then the kernel will maintain a stack for each thread.

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

blogs.msdn.com/b/oldnewthing/archive/2005/07/29/444912.aspx

this URL answers your questions.
>>
Do the threads have their own stacks, or share the process stack(s), or both?
>>

I think, there is no process dedicated stack. in other words , we can say, process stack same as initially created thread stack.

- siva.sai.2020 April 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What is a process: program in execution.
What is a stack: space use to hold the value of the temp variables and keep track of the flow control.
How many stacks can a process have:one (in most of the cases)
What is a thread: its can be think as a unit of CPU execution.
How many threads can a process have:depend on the size of the thread pool and OS
Do the threads have their own stacks, or share the process : threads have their own stack and registers but share the address space with the parent process.

- flopirate April 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Process: Its a program in execution.
Stack: Space used by a process for controlling its flow of execution and storing of its local variables.
Thread: It is an independent flow of execution which shares same address space as its parent process.
Yes threads have their own stack.

- Avi June 19, 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