Microsoft Interview Question for Software Engineer in Tests


Team: Windows Hyper-V
Country: United States
Interview Type: Phone Interview




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

There can be two possible solutions to this problem
I ) Use Print Spooler of OS
II ) Design specific program to handle prints

if we follow option (I) then life is simple, just put every print request we get to spooler and OS will mange by itself ( actually its a solution to producer-consumer problem )

if we follow option (II) then we would have to design priority scheduler as mentioned by @vgeek on any basis we like whether size, time of arrival or even user can be asked for priority if two print commands are given simultaneously. This would require us to code manually the work of spooler.

- NaMo June 30, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

The jobs in the printer are basically kept in a queue and if only one instance is there and several jobs to be printed are there then the printer prints the jobs on a first come first serve basis.
But when two or more instances of the word are running and simultaneous instructions are provided to print the job to the printer then the priority to the jobs should be given according to the size of the job. Suppose the size of one job is 100 kb and size of another job is 50 kb then the priority to first job should be given. Thus the printer driver could be designed on the basis of priority queue. To ensure it more we can use a counting semaphore where the less-size job holds the resources that is the printer driver until it is completely printed after which the resource becomes available to the next job for printing.

- vgeek June 27, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

yeah but why to give priority to the lengthier job? The average finish time will be more if we give higher priority to lengthier job. What am i missing?

- kaushik.hbk.007 July 22, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@kaushik The print time will be the same regardless. I don't see any advantage in the priority queue based on size. In fact, I would like the smaller document first but that's just me.

- david October 18, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Assumptions:
Printer has unlimited memory

We have two components:
1. Client driver on the machine
2. The service listening on the printer
On receiving a request to print, the client driver on the machine sends a notification to the printer about a print job. The printer stores the request in a FIFO queue. The printer has a different thread which dequeues from the queue and processes that job. While processing, it calls back the client driver and downloads the entire document to be printed.

This is very high level but you can decompose these components and decide on the different messages and contents of the message.

Plus, if the assumption of unlimited memory is untrue, there needs to be a secondary memory which is larger. Optimizations will be required to print multiple copies of the same doc in this case in order to avoid downloading the doc multiple times.

- Adi September 26, 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