1 APT Portfolio Interview Experience - Set 1 (On-Campus) 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Contents

1 APT Portfolio Interview Experience | Set 1 (On-Campus) 2


Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1
Chapter 1

APT Portfolio Interview


Experience | Set 1 (On-Campus)

APT Portfolio Interview Experience | Set 1 (On-Campus) - GeeksforGeeks


Round 1
Coding Assignment – TCP sender receiver communication with handling of duplicate and
out of order packets.
Scenario: An application receives packets from a server on the network. Each packet belongs
to a particular channel, and is also identified by a unique sequence number. Note that each
channel has its own sequence number series. So if the server is sending data for 10 channels,
you should expect to see packets starting with sequence number 1 for each of these 10
channels.
The network is such that after leaving the server but before reaching your application, these
packets could be

1. re-ordered; OR
2. duplicated; BUT
3. never dropped completely.

The goal of your application is to always apply the packet data in-order of (channel-specific)
sequence numbers and without any gaps. Of course in the real world, there will be more
work to be done, but we will ignore it for now.
You have to implement the function re_sequence_and_apply().
You can use any data structure for this purpose, including anything from C++ STL. If you
write your own data structure, please supply the entire definition of that data structure with
your solution.
Additionally, you will have also to implement the event_source interface to test your code
the any way you wish to. Your solution will be evaluated on the basis of correctness, as well
as, space and time complexity.

2
Chapter 1. APT Portfolio Interview Experience | Set 1 (On-Campus)

Code Snippet

#include <stdint.h>
#include <iostream>
  
struct event
{
    uint8_t channel_id;
    uint32_t sequence_number;
    uint8_t *pkt_data;
    uint32_t pkt_len;
};
  
classevent_source
{
public:
    virtual event* get_next() = 0;
    virtual void release_event(event* ev) = 0;
};
  
  
void apply_pkt_data( int8_t channel_id, uint32_t sequence_number,
                     uint8_t* pkt_data, uint32_t pkt_len)
    {
       std::cout<<"(" <<(int)channel_id<<","<<sequence_number
                <<","<<*(char*)pkt_data<<") ";
    }
  
  
void re_sequence_and_apply( int8_t channel_id, uint32_t sequence_number,
                           uint8_t* pkt_data, uint32_t pkt_len)
{
  
    /* This is the function that you need to code. It should apply
      the data in sequence for each  channel for which data is received.
      Once your code figures out which packet to apply next, it should
      call apply_pkt_data() as defined above */
}
  
// Driver program
int main ()
{
    // Instantiate your own implementation of event_source
    // here for testing.
    event_source* event_q;
    event* ev;
    while ((ev = event_q->get_next()) != NULL)
    {

3
Chapter 1. APT Portfolio Interview Experience | Set 1 (On-Campus)

        re_sequence_and_apply(ev->channel_id, ev->sequence_number,
                              ev->pkt_data, ev->pkt_len);
        event_q->release_event(ev);
    }
    return 0;
}

Round 2 (Around 35-40 minutes)


1. What is user mode and kernel mode?
—-> Kernel Mode
In Kernel mode, the executing code has complete and unrestricted access to the un-
derlying hardware. It can execute any CPU instruction and reference any memory
address. Kernel mode is generally reserved for the lowest-level, most trusted functions of
the operating system. Crashes in kernel mode are catastrophic; they will halt the entire PC.

User Mode
In User mode, the executing code has no ability to directly access hardware or reference
memory. Code running in user mode must delegate to system APIs to access hardware or
memory. Due to the protection afforded by this sort of isolation, crashes in user mode are
always recoverable. Most of the code running on your computer will execute in user mode.
2. Why do you need kernel mode in case of single user system?
—> Think in terms of hardware resources and I/O resources allocation, Traps, system calls,
Interrupts all takes place in kernel mode. For the execution of primitive and sensitive
instructions, kernel mode is necessary.
3. Why operations of kernel mode can’t be executed in user mode?
4. Can two processes generate same virtual address? If yes, then will there physical address
be different or same? Why same or why different?
5. What is trap? What is interrupt? Types of interrupt? How are they different? Do all
traps requires switching between modes?
6. How threads of a process having different stacks will share resources? How will threads
communicate?
7. In case on multi core, if T1 running on core 1 , T2 running on core 2, how will they
synchronize and communicate?
8. Some code snippet in C++ was given in which P1 and P2 processes were generating some
address. Address generated by P1 was initialized using dereferencing. Can P2 dereference
it?
9. Questions on Stack pointer.
10. Code Snippets were given on printed sheet. Asked what will be output of the code.
Mostly seg fault was there in the answers.
11. Some syscalls code was written but she explained me that code so patiently and then
asked where is the error? I did not remember the code.

4
Chapter 1. APT Portfolio Interview Experience | Set 1 (On-Campus)

Asked if I want to ask anything. I asked 2-3 questions about the company and what will I
be supposed to do? Asked about the work and profile and what company actually do?
She answered very interestingly. I liked it.
Round 3 (Around 1 hour)
Interviewer is just amazing. I did n’t feel uncomfortable even for a single second in this
round. Discussion just went on and on. It was just amazing as per my personal experience.
1. Complete discussion on coding assignment. Strategy and data structure used.
2. Design Data structure to save a large number of incoming packets if you have memory
constraints.
3. Where will you place Scheduler, Compiler, Dispatcher, MMU in the thread execution?
Explain everything in detail.
4. Do you know assembly code? Assembly code you used in thread library? How will that
invoke scheduler?
5. Segmentation fault can occur if you try to access address 1 incremented by stack pointer
as in SP= Sp +1?If yes, why? If not, why?
6. Discussion on Advanced COmputer Networks Course : New TCP protocols : Vegas,
Reno, Wireless westwood etc
7. Design a data structure (can use STL) to capture packets if incoming data is coming at
a very fast pace keeping in mind the out of order delivery and duplicate packets. Efficient
in terms of handling all cases.
—> Latency should be minimum in processing
—> Capability to manage more than 10000 out of order packets.
8. Explain 3-way handshake. What will happen if SYN is dropped, if SYN+ACK is dropped,
if ACK is dropped? On dropping of last ACK, can sender still send the data over the channel?
WIll it be reliable?
9. Asked questions on implementation of pthread library – CSP Assignment. About Sched-
uler, Compiler and how scheduler will work in dispatching of threads. Complete explanation
of round robin scheduler.
10. A code was given :

int *f1(int a)
{
    int *c = &a;
    *c = *c*10;
    return &c;
}
  
int *f2(int *b)
{
    int c = *b*10;

5
Chapter 1. APT Portfolio Interview Experience | Set 1 (On-Campus)

    return &c;
}
  
int main()
{
    int a = 10;
    int *add1=f1(a);
    int *add2=f2(add1);
    print (*add2);
}

Will this code compile? If yes, what is the output? If No, why?
How memory allocation and deallocation on stack will work?
A long discussion on segmentation fault. if yes , why? if No, yes? Will the memory swapped
off the stack space when function returns or values of local variables still resides unless next
function overwrites. What actually happens?
Asked me to run the code when I was leaving. I asked can I take this piece of code with
me? he said No, I can’t disclose question and smiled. Then, I said It’s okay. Question is in
my mind. I will execute it for sure.

Source

https://www.geeksforgeeks.org/apt-portfolio-interview-experience-set-1-on-campus/

You might also like