The code
Embedded Linux C. It compiles. There are 3 real bugs in it: the kind that pass a bench test and fail in the field.
static DEFINE_SPINLOCK(frame_lock);
static u8 frame[64];
static size_t frame_len;
static irqreturn_t sensor_irq(int irq, void *dev)
{
spin_lock(&frame_lock);
frame_len = sensor_fifo_read(frame, sizeof(frame));
spin_unlock(&frame_lock);
return IRQ_HANDLED;
}
static ssize_t sensor_read(struct file *f, char __user *buf,
size_t count, loff_t *off)
{
spin_lock(&frame_lock);
memcpy(buf, frame, frame_len);
spin_unlock(&frame_lock);
return count;
}What an interviewer expects
- Point to each line you'd stop in a code review.
- Say what actually breaks: the failure mode, not just the rule it violates.
- Fix it, then defend the fix when asked the follow-up.
The bugs, reference fixes and the follow-up question are in the practice app, after you've tried it.
Companies that test this
Matched on the skills each company's embedded roles emphasise.
AMD IndiaChipmaker · India hiring: MediumHCLTech ER&DEngineering services · India hiring: HighInfosys Engineering ServicesEngineering services · India hiring: HighIntel IndiaChipmaker · India hiring: HighMistral SolutionsEngineering services · India hiring: MediumSaskenEngineering services · India hiring: MediumTata ElxsiEngineering services · India hiring: HighTCS (engineering and IoT)Engineering services · India hiring: High
Related challenges
Serial GPS reader on LinuxEmbedded Linux · Medium · 4 bugs · ~6 minPing diagnostic on a Linux gatewayEmbedded Linux · Medium · 3 bugs · ~6 minGPIO through /dev/memEmbedded Linux · Medium · 3 bugs · ~6 minTouch driver interrupt handlerEmbedded Linux · Hard · 3 bugs · ~7 minADC over spidevEmbedded Linux · Medium · 3 bugs · ~6 min
Flag the lines, say what breaks, then fix it and build it with clang in your browser.
Find the bugs