Cisco Systems

  www.cisco.com
  www.cisco.com

Interview Question

Software Engineer Interview Boxborough, MA

Given 3 systems: system 1 reaches 0xFF, then system

  2 increment by 1. Everytime system 2 increments, system 3 would fetch the package. When can there be a problem? What is the problem with this system? How can we fix this?
Answer

Interview Answer

1 Answer

0

Problem:
system 2 counter can overflow (that answers what and when) or will overflow eventually (if its also 1 byte that after 256*256)

Solution:
Well, if its interrupt based (i.e.interrupt for every tick), we put boundaries i.e system2 == 0xFF , reset system2 counter
if its polling, its possible that when we check , system2 could have increased by 'k' amount (where k=0,1,2,....,0xFF), in that case if system1 increments periodically, we can time-bound our polling to a multiple of 256*m periods and fetch 'm' packages, making sure that 0xFF falls on that boundary. RTOS will be required to guarantee our task a CPU slice every 256*m intervals
if its random, interrupt polling is better, else we have to check for overflow,
i.e at time 't' , system2 = c1
and time 't+k', k>0 , system2 = c2,
then if c2 < c1 => overflow and total ticks is (0xff - c2) + c1

Anyway, more you think, you can get even better approaches and if you know which OS and CPU is being used , it can help too

R on Jun 24, 2014

Add Answers or Comments

To comment on this, Sign In or Sign Up.