← Omnissa Interview Insights

Omnissa·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Interviewed for a Software Engineer role at Omnissa and got a concurrency question that looked straightforward on the surface but had a few gotchas worth knowing about going in.

Questions Asked (1)

Q1

Given a positive integer n, print all integers from 1 to n in order using exactly two threads running concurrently: one thread handles odd numbers and the other handles even numbers. The output must be correctly ordered, and you must use proper synchronization primitives to coordinate the threads without deadlock.

Algorithms & Data StructuresTechnical Trade-offsSystem Design
Author's notes

I knew roughly what to do but fumbled the synchronization design at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a shared counter and a mutex with condition variables to coordinate two threads: one prints odd numbers, the other even. Each thread waits until the counter matches its parity, prints, increments the counter, and signals the other thread. This ensures ordered output and avoids busy-waiting.

Pro tip: Mention that using condition variables with a mutex is more efficient than busy-waiting, and discuss how to handle the termination condition to avoid deadlock. Also, note that the solution can be extended to more threads with a similar pattern.

1. Clarify requirements and constraints

Confirm that n is positive, output must be in order, and exactly two threads are used. Discuss whether n can be large and if performance matters.

2. Design synchronization mechanism

Choose a shared counter and a mutex with condition variables. Explain how each thread waits for its turn based on parity and signals the other after printing.

3. Implement thread logic

Write pseudocode for odd and even threads: lock mutex, wait until counter parity matches, print, increment counter, signal other thread, unlock. Include termination when counter exceeds n.

4. Address edge cases and termination

Handle n=1 (only odd thread prints) and ensure both threads exit cleanly. Discuss potential deadlock scenarios and how condition variables prevent them.

5. Analyze trade-offs and alternatives

Compare condition variables vs. semaphores vs. atomic flags. Discuss performance implications and scalability to more threads.

Key Points to Mention

  • Use of mutex and condition variables for synchronization to avoid busy-waiting.
  • Shared counter to track the next number to print.
  • Parity check to determine which thread should print.
  • Signaling the other thread after printing to ensure ordered output.
  • Termination condition: when counter exceeds n, both threads should exit.
  • Avoiding deadlock by ensuring proper lock/unlock and signal/wait patterns.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.