Cisco Systems Interview Question for Software Engineer / Developers






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

2. calloc beasically puts zeros when allocation memory. The program crashes because it tries to pu in 0s to all the page table entries.

So the page table is 4096 bytes(somthing like that).. so wehn all the pages are filled that when the program crashes... It does not crash after allocatiing all the 1gb.

3. Answer: P1 will be interrrupted. So the critical operation might have a problem.

Basically when critical operation needs to be done.. have spin locks.. which exist over both p1 and p2.

but again using spin locks has to be done carefully bcoz... they might end up getting into a deadlock(i dint understand how. kindly someone explain).

Deadlock can be avaided if.. we have a interruot handler.. in p1 which disables the interrupt handler and then graps the spin lock..


these things are complex.. and I have made it even more cryptic... the problem is that i did not completely understand what the interviewer was talking..(my first interview in life)... SO if people could elaborate on these lines... it would be helpful for me and the community...

- backbone March 29, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

AFAIK, disabling interrupt on a single processor on a SMP used to disable interrupts on all processors on Linux kernel 2.2. but it was deprecated in 2.4 and removed in 2.6. I didn't go too deep into what is the implementation in the current kernel. One good way to achieve mutual exclusion is using Anderson spin lock.

Look here for a discussion on alternatives:
www.cs.washington.edu/homes/tom/pubs/spinlock.pdf

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

OK. Disabling interrupt reporting on a CP via cli is a substitute for locking for an uniprocessor host, as long as it is a non-preemptive kernel, or preemption is disabled.
Cpu-s do not "throw" interrupts. ( Maybe one processor can interrupt another via IPI)
In any case, a cli will suppress reporting any interrupts including IPI. The spinlock link above will probably confuse the average reader as it deals with esoterica of various spinlock implementations (not related to the original question whatsoever) . The questioner is probably looking for to having some form of locking in place to protect shared data in addition to the cli, because another (running) cpu may access such data, despite of interrupts being disabled on the current one.

- d3nk3r April 08, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

3) "We know disabling interrupts works only if it is single processor(i.e local disabling of interrupts).

Consider this case where we have a SMP(symmetric multi proc) the processor. Processor-1 wants to perform some critical operation so it disables all the interrupts.

What will happen when processor-2 throws an interrupt"

I think the answer to this is if the two interrupt handlers are not using any synchronization mechanism, it will create problem for critical code of interrupt handler-1.
How can be prevent the critical code from being interfered? Well lets assume if the critical code was to operate on some shared resource then it can be placed under spinlock.
or if the question is trying to ask what if they are not operating on shared resource but we still want that first interrupt service routine should get it's work done without any interruption. I think the only way that could happen would be by disabling the device interrupts. ( by writing to interrupt dsiable register of device)

- tarot May 25, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

About 3., one of the question is WHY disabling interrupt only works in single core processor. The reason to disable the interrupt in your case is you want to implement mutual exclusion. Besides memory shared mutex implementation, there is another way to provide mutual exclusion, which is to disable the interrupt. By disabling interrupt, a process will not be context switched out of CPU, if this process doesn't make any system calls which cause process to sleep.

Therefore, on uni-processor system if you disable the interrupt, you will be happily executes your critical section because you can't possibly be preempted. However, it doesn't work in multi-core system, because your process will only hold one core, but at the same moment another thread can execute the critical section your process is working. So in this case this implementation of mutual exclusion fails.

- Hank Lee May 11, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Your answer is pretty good, and the previous on is a little misleading. This is the content in the standard operating system textbook.

- David Tan August 16, 2008 | Flag


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