# Specification-1 Answers
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.
A1. [HG] I have posted the instructions to fix the script on Moodle. Adding the link here:
https://iiitaphyd-my.sharepoint.com/:f:/g/personal/hitesh_goel_research_iiit_ac_in/EkVPVt7wKcBPtoiqtrBrKwQB8boeFAiJojHig3al-T3hhg?e=W2fF07
If following these steps still doesn't work, try running
```bash=
test_1
```
inside the xv6 kernel (i.e. after booting xv6). The output should match the output in `xv6-initial/tests/1.out` file.
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.)
A2:[HG] Not required to handle test_2. Also mentioned in the assignment thread.
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?
A3:[HG] No, I believe the file is correct.
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.
A6:[HG] Use the source code provided with github classroom.
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?
A7:[HG] Since bootup.
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`
A8. [HG] It's fine as long as the code works.
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
```
A10. [HG] Your handling of the trap instruction (interrupt) is incorrect.
Q11. Can we use <semaphore.h> or are we supposed to implement it ourselves.
A11. [HG] Yes it's allowed.
# Specification-2 Answers
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
A1. [HG] This shouldn't be the case.
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?
A2. [HG] The time slices provided are for the round robin queues of each priority. You are supposed to make an assumption for the time limit according to which aging will take place.
Q3. In schedulertest.c , what eactly are rtime and wtime?
A3. [HG] The avg wait-time and run-times of the processes in queue.
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?
A4. [HG] Error with the code. First make sure the code runs fine for CPU=1
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?)
A5. [HG] Refer to A2.
Q6.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
A6. [HG] The latter.
Edit: Due to some confusion, both will be considered correct. (It basically depends on the schedulertest you are using).
Q7. Q7. Are we allowed to modify aspects of ``schedulertest`` that deal with printing?
A7. [HG] Yes.
Q8. What should be the syntax of running the desired scheduler like when should we mention whether we want to run "FCFS" or "MLFQ" ?
A8. [HG] `make qemu SCHEDULER=FCFS`
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?
A9. [HG] It should stay as is.
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?
A10. [HG] Sequence for FCFS is provided above. RR will be correct because it is the default implementation of xv6.
Q12. In MLFQ, queue 4 is to be RR'ed as per spec, the remaining queues are FCFS?
A12. [HG] All are RR.
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) ?
A13. [HG] Yes.
# Specification-3 Answers
Q1. How do we make a graph report out of the schedulers we have implemented??
A1. [HG] Discussed in tutorial.
Q2. Can we include the report in the README of our mini-project-2-... repo?
A2. [HG] A readme is fine, but you can also convert the readme to a pdf file using `pandoc`
# Specification-4 Answers
Q1. In rock paper scissors, are we supposed to use threading, functions like select/poll, or neither?
[VB: You don't **need** to. But you are free to use them if you want to.
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?
[VB]: It's been updated to say 4+4
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?
[VB]: Sure. Sure - you can assume that while the other player is typing, the first player will not type.
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?
[VB]: The sender is supposed to divide the data. Yes, the receiver should combine the chunks. The assignment has been updated to reflect these changes.
Q5. In the specification of Part B, is it necessary to use the select() function to wait for the ACK bit for some time?
[VB]: No, it is not necessary. Also, you aren't exactly supposed to wait for an ACK signal - you must send other chunks even if you don't receive an ACK signal (Only resend a chunk if you notice that you haven't received an ACK packet for it - the chunk - after a timeout)
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?
[VB]: Most of the marks assigned for this part will be based on error handling. It's alright if your code resembles the given resources for the most part. You may take it as user input or predefine it for the basic implementation. However, rock, paper and scissors must 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)?
[VB]: Two way connection.
Q8. Can we include the report in the README of our mini-project-2-… repo? (for Part B).
[VB]: Sure. However, we would prefer it if you could add it as a separate README within the partB directory.
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?
[VB]: Description
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?)
[VB]: As long as you know exactly when all the packets have been received anything works.
Q11. Do we have to run the sending and receiving process concurrently using multiple threads?
[VB]: You don't need to use 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)?
[VB]: Consider an example (timeout = 3.2 seconds, time between packets = 1 second)
```
[time]: activity (NOTE: EDITED)
[1]: Send packet 1
[2]: Send packet 2
[3]: Send packet 3
[4]: Send packet 4
[4.2]: check if ACK for packet 1 was receieved. If it wasn't then resend packet
[5]: Send packet 5
[5.2]: check if ACK for packet 2 was receieved. If it wasn't then resend packet
[6]: Send packet 6
[6.2]: check if ACK for packet 3 was receieved. If it wasn't then resend packet
etc.
```
_Edit_: NOTE: You don't need to check whether the ACK for packets was received exactly when the timeout occurs - it's fine if you check for the ACK for packet 1 at like 4 seconds instead of 3.2 seconds (But, don't wait for an unreasonable amount of time)
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?
[VB]: Please add another question mentioning which part the question is referring to.
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?
[VB]: No. Only one of them will be sending messages at a time. Say you start sending packets from the client to the server. The server should start sending packets after it has received all the chunks from the client.
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)?
[VB]: Sure
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
[VB]: 1, 2, 3, 4 (You wait until you get all the chunks)
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?
[VB]: Preferably yes. However, you may hardcode the data/take it as CLI argument for all parts except for rock-paper-scissor
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?
[VB]: Yes, this is fine.
Q19. For part B, is it ok even if I do not use structs and just send a concatenated string (chunk no. + string part)?
[VB]: Sure.
Q20. For part B, can i send the any acknowledgement pack as i wish (not only string but also a struct or integer)?
[VB]: Sure
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
```
`Ans`
[VB]: Yes (as long as you don't wait for ACK for 1 before sending 2)
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)
[VB]: Considering that the specifications ask for bidirectional comms, I can't allow this (as in, give full marks).
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?
[VB]: Considering that we've asked for only one server and one client comms, the codes for both of them might as well be the same if you want to implement it in that way.