---
# System prepended metadata

title: Mini Project 2 Questions

---

 ***Please ask any doubts under the particular question's specification heading only. 
Ensure you are following the correct numbering while asking doubts.***




# General Questions

Q1. Why can't we include <stdio.h>? When I do so, it says: No such file or directory.


# Specification-1 Questions

Q1. Im getting this text in tests-out/1.err when i run ./test-getreadcount.sh:

/usr/bin/env: ‘expect’: No such file or directory
and tests-out/1.out is empty. Is it an implementation or is there something missing?

Update: I installed expect and now im getting another error as:

expect: spawn id exp4 not open
    while executing
"expect "$ ""
    (file "../../tester/run-xv6-command.exp" line 25)
 
according to the issue: https://github.com/remzi-arpacidusseau/ostep-projects/issues/12 this should be resolved when i install gawk,   but i already have it installed.

Q2. Are we expected to write a getreadcount() code that passes test-2? (currently, it passes test-1 just fine.) Since it is just a 5 mark syscall in specification-1, and from what it seems, it requires me to understand concurrency and locks to make my code thread-safe? (Citing https://github.com/ossu/computer-science/blob/master/coursepages/ostep/Project-1B-initial-xv6.md as my source for these assertions.)

Q3. Is there an error in the alarmtest.c file ? The file is giving errors due to undefined reference to sigalarm and sigreturn. Is there something we should include in the file?

Q4. in Sigalarm and sigtest when 2,periodic is passed in sigalarm im trying to get argddr and argint out of it but they are giving zero for it, thus my apparently correct function is not working correctly

Q5.While implementing sigalarm and sigreturn i am creating a user level function to test if it working fine but when it calls sigalarm the syscall is always taking a negative time intervel because of which sigalarm is not being handled..Can u give a basic idea on the implementation of sigalarm?

Q6. Do we have to copy paste the source xv6 code ,that we got from cloning the xv6-riscv git repo and using the mit website commands , into the kernel folder of the git repo of this project and then make changes into it or the code in the repo is enough to be executed ? if it is how to run it as some files are different in both.

Q7. For getreadcount , do we need to return the number of Read calls in the current process or the number of read calls since bootup till now?

Q8. Altough the question mentions that the function signature should be `int getreadcount(void)`, does it make a difference if I use `uint64 getreadcount(void)` instead? I am getting `incompactible pointer types` error when I use `int` instead of `uint64`

Q9. What is the expected behaviour incase of a timer interrupt while a handler is running? Should the scheduler take over or 

Q10. Why does the below happen when I run alarmtest in xv6? Am I handling something wrong?
```
xv6 kernel is booting

hart 2 starting
hart 1 starting
init: starting sh
$ alarmtest
test0 start
...scause 0x000000000000000f
sepc=0x0000000080002b20 stval=0x0000000000000000
panic: kerneltrap
```

Q11. Can we use <semaphore.h> or are we supposed to implement it ourselves.

Q1. Getting same issue as in Q1 even after doing all the correction.
(Please whoever who posted this question even if you got any solution mention it.)

# Specification-2 Questions

Q1. When i keep CPU=1 in makefile and use scheduler as fcfs it compiles but shows "panic released" but works well for CPU=2

Q2. In MLFQ, point 6 says:
```A round-robin scheduler should be used for processes at the lowest priority queue.```
For the lowest priority queue, given time slice is 15 ticks. Is this the expected time slice for the round robin scheduling for this priority queue, as well? Or, can we use the default 1 tick time slice?

Q3. In schedulertest.c , what eactly are rtime and wtime?

Q4. Process 5 finished
Process 6 finished
Process 9 finished
Process 7 finished
Process 8 finished
PPPrroorcoecsecsess  s02  ffiinniss hiesh1d 
feidn
isPhPerdo
creoscse ss3  4f fiinniisshehde
d
when  I run schedulertest, the output is as given as above for RR implemented in XV-6
printing of process is jumbled . Is the error with schedulertests code or my code? 

Q5. For the sake of clarity one last time, are we expected to implement round robin scheduler for each priority queue in MLFQ? (this was not mentioned explicitly in the specification doc, it was just said that the lowest priority queue will have RR.) For the round robin, the timeslice is the same as that of the MLFQ queue demotion time slice, right? (For example, for PQ 1, each process runs in round robin for 3 ticks.)

In essence, what is the expected run order for this example?
```
PQ 0 -> PID 1, PID 2, PID 3
PQ 1 -> PID 4, PID 5
```
Are we expected to run PID 1, PID 2 and PID 3 in round robin with a time slice of 1 ticks (assuming they do not exceed their time slice)?
After that, are we expected to run PID 4 and PID 5 in round robin, with a time slice of 3 ticks (assuming no new processes enter and these 2 processes do not get aged up?)

Q6. Which Processes should run first: I/O bound processes or CPU bound processes in FCFS and MFQ ??
    That is the output for FCFS should be:
    
    Process 5 finished                        Process 0 finished
    Process 6 finished                        Process 1 finished
    Process 7 finished                        Process 2 finished
    Process 8 finished                        Process 3 finished
    Process 9 finished          or            Process 4 finished
    Process 0 finished                        Process 5 finished
    Process 1 finished                        Process 6 finished
    Process 2 finished                        Process 7 finished
    Process 3 finished                        Process 8 finished
    Process 4 finished                        Process 9 finished
    
where, Processes 0, 1, 2, 3 and 4 are I/O bound processes and Processes 5, 6, 7, 8 and 9 are CPU-bound processes

Q7. Are we allowed to modify aspects of ``schedulertest`` that deal with printing? 

Q8. What should be the syntax of running the desired scheduler like when should we mention whether we want to run "FCFS" or "MLFQ" ?

Q9. Assuming a process in PQ1 is about to complete its time slice but before doing so, it performs an IO. Should we restore the time slice (assuming we are maintaining a count of the time slices that a given process has completed) back to 0, or should it stay as is even if it makes an IO and the next time CPU executes that process, it continues from where it left off and demotes it to lower PQ?

an example: 
PID 2 is in PQ1, it completes 2 time slices and then performs IO. Should the time slices completed be reduced back to 0, or next time it comes, it should become 3 and then be demoted to PQ3?

Q10. How do we know if our schedulertest is correct or not? what is the expected output sequence for processes to be finished in RR/MLFQ/FCFS? 

Q11. In continuation to Q11, if there is some fixed sequence for any of the scheduling algorithms (fcfs/mlfq/rr) please provide the expected sequence (please.)

Q12. In MLFQ, queue 4 is to be RR'ed as per spec, the remaining queues are FCFS? 

Q13. What does 'aging' mean in MLFQ? Should we implement priority boost and lowering priority when time slice has been completely used(as discussed in class) ?

Q14. For the Q5 Asked above kindly give a detailed answer for our understanding please..

Q15. (Ref A6) Should this be the output for FCFS for any number of CPUs?

Q16. when i run usertests for MLFQ ,it is not printing anything for textwrite..is this supposed to happen?

# Specification-3 Questions

Q1. How do we make a graph report out of the schedulers we have implemented??

Q2. Can we include the report in the README of our mini-project-2-... repo?

Q3. Is it compulsory to submit report(as my late days are completed)?


# Specification-4 Questions

Q1. In rock paper scissors, are we supposed to use threading, functions like select/poll, or neither?

Q2. In rock, paper, scissors, the marking says it is 3 + 3 for UDP and TCP, however this is meant to be for 8 marks. What are the other 2 marks allocated for?

Q3. For the rock, paper part am I allowed to use an extra command line argument for convenience to denote which player will go first?
Also can I assume that while the other player is typing, the first player will not type? Or do I need to somehow try and block inputs while the other player types?

Q4. In the specification for Part B, it is said,
```
The receiver must divide the data (assume some text) into smaller chunks (of a fixed size). 
Each chunk is assigned a number which is sent along with the transmission (use structs).
```
Is the receiver supposed to divide the data into smaller chunks? Or is the sender supposed to do this? If the latter, then is the receiver expected to combine those chunks back to correctly interpret original data?

Q5. In the specification of Part B, is it necessary to use the select() function to wait for the ACK bit for some time?

Q6. In Part A, what exactly are we supposed to do for the first 4 points? The code for that the specification demands has already been given in the github links part of the references? What do we need to modify? Should the data being sent/recieved be taken as user input?

Q7. In part B, are we supposed to implement a 2-way connection (both the parties send data to each other) or just a client-server model (just the client sends data to the server)?

Q8. Can we include the report in the README of our mini-project-2-... repo? (for Part B).

Q9. In the report for question 2, do we need to include code or just a description of what we would do for flow control?

Q10. Are we absolutely required to send the number of packets to the receiver? Or, can we implement some other way of knowing when a message transmission has ended (say, some sort of flag within the "packet" itself?)

Q11. Do we have to run the sending and receiving process concurrently using multiple threads?

Q12. What exactly do we mean by "the sender shouldn’t wait for receiving acknowledgement for a previously sent chunk before transmitting the next chunk"? Does it mean that after timeout (i.e. ACK was not received) we send other package and check for it's ACK (not the previous one)? 

Q13. Do the client and server have to send multiple messages to each other, or is one message sufficient? Do the message(s) to be sent need to be taken as user input or can they be hard-coded/read from a file? 

Q14. Can the client and server send/receive messages to/from each other at the same time? If not can you give an example of how they are supposed to exchange messages?

Q15. For Part A, rpc, is having two separate code files for client A and client B acceptable (with the only difference being port number)?

Q16. "After the receiver has data from all the chunks, it should aggregate them according to their sequence number and display the text."Does this mean that when 1,2,3,4 are sent but 2 is missing it should print 1,3,4,2 or 1, 2, 3, 4?

Q17. How should the data be sent from one party to another? Would the client and the server be sending data that has been added as input by the user in STDIN?

Q18. For RPS, I am able to get the entire code working but I am only defining the server port. I have a piece of initiation code to get the server to recognize the two clients that send the initiation request, instead of assigning fixed ports for clients(as that was causing some issues for me). Is this okay? Or do we compulsarily need to have 3 ports defined - one for server and two for clients?

Q19. For part B, is it ok even if I do not use structs and just send a concatenated string (chunk no. + string part)?

Q20. For part B, can i send the any acknowledgement pack as i wish (not only string but also a struct or integer)?

Q21. Is this valid for part B?
```
[+]Chunk 0 sent
[+]Received acknowledgment for chunk 0
[+]Chunk 1 sent
[-]Did not receive acknowledgment for chunk 1
[+]Chunk 2 sent
[+]Received acknowledgment for chunk 2
[+]Chunk 1 sent
[-]Did not receive acknowledgment for chunk 1
[+]Chunk 1 sent
[-]Did not receive acknowledgment for chunk 1
[+]Chunk 1 sent
[-]Did not receive acknowledgment for chunk 1
[+]Chunk 1 sent
[+]Received acknowledgment for chunk 1
```

Q22. Is it acceptable to implement only unidirectional communication? As in, the server only sends ACK packets, and client only sends data. (The psuedo-protocol will be flexible enough to accomodate the case of the server sending the data)

Q23. Is it not possible to duplicate the client's code in the second half for the server, and vice versa, to enable dual communication?

Q24. For partA/basic, can we assume the 'text' to be of small size?

Q25. In partB, can we assume that the time difference between sending a packet and receiving the acknowledgement back is 0 ?

Q26. Can we use fcntl.h library and time.h library for Part B?

Q27. Can we use select() function for Part B?

