Google Interview Question for Software Engineer / Developers


Team: SRE
Country: India
Interview Type: Phone Interview




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

new operator allocates memory and (optionally) call object constructor.

there are different memory allocators, e.g. simplest one is a memory pool
where data is allocated in chunks of fixed size, typically used by a firmware.
In general memory allocator is a quite complex to design because it should support
allocation of arbitrary length objects, take care of fragmentation, be reentrant for multi-threading apps and provide some debugging facilities..

i am not sure what this has to do with paging mechanism
which is part of virtual memory ?

as far as i know there is a hardware data structure, called TLB. Whenever
processor serves a memory request, hardware compares a part of the requested address
with entries in the TLB (loaded pages). If no match is found, an interrupt is thrown
and OS kernel is supposed to preload a missing page from external memory and then resume an interrupted instruction

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

new operator will try to allocate memory first.
. if there is still enough space in current memory map, then a pointer to that area is returned.
. otherwise, break() system call will be called to allocate a new virtual memory area for the process. and the pointer is returned to the process

the while the new object got initialised, the first time access to the memory returned, it may cause a page fault if no physical page is allocated for the specific address, an exception that will enter kernel mode again. the kernel will allocate a new page for the process and back to user mode again. the data access as usual.

- gachen May 21, 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