Sunday, March 31, 2019

Operating Systems Tasks and Programming Lab

Operating Systems Tasks and Programming science lab lab Activity 1 Operating Systems Tasks and Programminga) Future of operating systems.Report on the future of operating systems hereb) Programming activityC++ allow exploitation namespace stdint main() int id = 6669447string name = Salman Mohammed Fazalint reverberation = 0for (int i = 0 i cout return key++ // gain counterif (counter == id-1) //if counter = last kindleracter of IDcout counter = 0 //reset counterJAVApublic class rill public static void main(String args) int id = 6669447String name = Salman Mohammed Fazalint counter = 0for (int i = 0 i System.out.print(name.charAt(i)) //print examplecounter++ //increase counterif (counter == id-1) //when counter is last voice of IDSystem.out.println() //new linecounter = 0 //reset counterPYTHONname = Salman Mohammed Fazalid = 6669447for i in send (0, len(name), int(id-1)) for every n personasprint(nameii+ int(id-1))) slice and print string mandate Outcome ( identical for each) research lab Activity 2 Linux Command Line (Commands and outcomes from a series of small tasks that require use of a shape of Linux commands)How spend a penny Portfolio1 directory call for/ sp ar/executable only for you and your group. That is, not for others. Show take the stand of this with ls command.How downloaded the script http//www.centerkey.com/tree/tree.sh to your home directory using wget and make it executable.Making DirectoriesHow defecated a 207se directory in your Portfolio1 directory.How created government issueed directories for the labs. i.e. lab1 and lab2 etc. reason of transferring lab1 activity into appropriate directoryEvidence of make directory activities using tree.shDisplay todays date and using the cal command study the calendar month that you were born. Move into the lab1 directory and use the appropriate command to show the current directoryWhat is talk, write and wall argon forThe Talk command is used for exchanging messages with other user s who are logged on the same network.The Write command is used to send messages to users in the same network. This one-way only.The Wall command is used to send messages to all the users in the entire network. This is limited to the admins only.What command keep ons the effects of those three commands from interrupting you.To prevent users from interrupting you, you can use the Mesg command. This command basi bring forwardy enables or disables users from writing to your terminal. Mesg y to Allow access and Mesg n to deny access.The song in song.txt. development wc the outcome of words and lines in the cross- burden.Using grep to get the lines curbing and and the number of the lines contain and in the document give ptyalize to show the contents of the shoot down. appropriate Linux command to see if the two agitates differ and how they differ.Use sift to sort the charge up and redirect the payoff to a new saddle called song2.txtUse sort and rev to reverse the sorted content s of song.txt and append the widening to song2.txt conglomeration memory used and the supply memory available attain out how you can display your username on the screen.List the kneades that are running.What are the differences between the Linux commands less, to a greater extent and most.The much than command works similarly to the cat command by displaying contents of a load, however the more command, you persuasion bits of the text (a screenful), and is in a forward-scrollable manner.The less command is similar to the more command, however with this it is possible to scroll both, forward and backward.The most command is more like the less command, but the only difference is, it is possible to office several files at once with this command.The basic syntax for these commands aremore less Lab Activity 4 Bootloaderlegal brief description of the Lab activity and what you didThis weeks task was to create a smasherloader using Assembly which embroil my student details and a t riangle of dots. We then have to boot the bootloader with bochs.Boot pragma linux with bochsMake a bootloader that displays your student details and triangle observeed bootloader formula to display your student details and triangleBITS 16ORG 0x7C00top Put 0 into ds (data segment) Cant do it directlymov ax,0x0000mov ds,ax si is the location telling to the data segment of the string/char to displaymov si, monosodium glutamatecall writeString See belowjmp $ SpinwriteStringmov ah,0x0E Display a chacter (as before)mov bh,0x00mov bl,0x07nextcharLodsb Loads SI into AL and increases SI by one Effectively pumps the string through ALcmp al,0 End of the string?jz doneint 0x10 BIOS interruptjmp nextchardoneretmsg db Name Salman Fazal,13,10, Email emailprotected, 13,10, Fav Module 207SE ), 13,10, DOB 01/08/1996 21 ,13,10, Std ID 6669447 Null-terminated propagation 510-($-$$) db 0dw 0xAA55Output from Bochs showing student details and triangleLab Activity 6 keeping ManagementMemory Allo cation Activities due to the codification outputs being excessively long, I have just snipped a portion of the result, however all of my answers match with the results in the law.* NULL = Memory address not allocated.First-FitBest-FitWorst-FitPaging ActivitiesFIFO42775639322 pageboy debut 044445559999varlet adit 12222666622 rogue entranceway 2777733333Page recessFFFHFFFFHFHPage deformity center 842775639322Page Entry 044444666666Page Entry 12222233333Page Entry 2777779999Page Entry 35555522Page FaultFFFHFFFFHFHPage Fault Total 8RANDOM42775639322Page Entry 044445666622Page Entry 12222229999Page Entry 2777733333Page FaultFFFHFFFFHFHPage Faults Total 842775639322Page Entry 044444449999Page Entry 12222222222Page Entry 2777733333Page Entry 35666666Page FaultFFFHFFFFHHHPage Fault Total 7The stochastic algorithm did not give me the same result as the way I solved it. This is because There is no specific rule/method on what memory block to be replaced. Each judgment of conviction a process needs to be moved to a memory block, a random memory block is chosen in order to swap the process.Evidence of running reckonLab Activity 7 yield Brief description of the Buffer ActivityThis weeks task involved using cushions in terms of contracting and writing from a fileCommented Buffer.c codeinclude // program library for file control optionsinclude //library for popular determination excessivelylsinclude // forefront fileinclude //file IO restrict BUF_SIZE five hundred //sets original coat of it to 500define OUTPUT_MODE 0700 //defines the output mode, sets file permissionsint main(int argc, char *argv) // do variablesint in_fd, out_fd // stand up associated numbers on both filesint rd_ size = 1 // form sum of money of bytes in airplane pilot (final should be 500)int wr_size //hold occur of bytes on the output filechar bufBUF_SIZE //initialise buffer and its sizeif (argc = 3) // develop for slump number of arguments eliminate(1) //exit if too many a( prenominal) an(prenominal) or too few parametersin_fd = open(argv1, O_RDONLY) //open file to call for from ( see only)//if file isnt found, variable go forth have a negative numberif (in_fd exit(2) //exit if files emptyout_fd = creat(argv2, OUTPUT_MODE) //create the output file//if file isnt created, variable will have a negative numberif (out_fd exit(3) //exit if cannot write to the file dapple (rd_size 0) // speckle characters (in file) put away existrd_size = empathise(in_fd, buf, BUF_SIZE) //read the file into bufferif (rd_size exit(4) //exit if fracture darn readingwr_size = write(out_fd, buf, rd_size) //write from buffer into fileif (wr_size close(in_fd)close(out_fd) //close both of the files if error foundexit(5) //exit if error enchantment writing modify the code to so that it prints if an error has occurred or if a file is successfully created with the content of the review in it.After running code what is in hamlet.txtinclude //library for file control optionsincl ude //library for general purpose toolsinclude //header fileinclude //file IOdefine BUF_SIZE 500 //sets buffer size to 500define OUTPUT_MODE 0700 //defines the output mode, sets file permissionsint main(int argc, char *argv) //Define variablesint in_fd, out_fd //hold associated numbers on both filesint rd_size = 1 //hold amount of bytes in buffer (final should be 500)int wr_size //hold amount of bytes on the output filechar bufBUF_SIZE //initialise buffer and its sizeif (argc = 3) // hinder for correct number of argumentsprintf(Error Invalid number of parameters passed.)exit(1) //exit if too many or too few parametersin_fd = open(argv1, O_RDONLY) //open file to read from (read only)//if file isnt found, variable will have a negative numberif (in_fd printf(Error institutionalise not found.)exit(2) //exit if files emptyout_fd = creat(argv2, OUTPUT_MODE) //create the output file//if file isnt created, variable will have a negative numberif (out_fd printf(Error load not created.)e xit(3) //exit if cannot write to the filewhile (rd_size 0) //while characters (in file) still existrd_size = read(in_fd, buf, BUF_SIZE) //read the file into bufferif (rd_size printf(Error Cant read from file.)exit(4) //exit if error while readingwr_size = write(out_fd, buf, rd_size) //write from buffer into fileif (wr_size close(in_fd)close(out_fd) //close both of the files if error foundexit(5) //exit if error while writingprintf(Operation Successful)After compiling and running the code, the hamlet.txt file contained the rent same text that was in the main review.txt fileEvidenceUpdated buffer.c code to show how many character are read to buffer, how many character read at a time into the buffer, how many words in the document and how many times the buffer is fakeinclude //library for file control optionsinclude //library for general purpose toolsinclude //header fileinclude //file IOdefine BUF_SIZE 500 //sets buffer size to 500define OUTPUT_MODE 0700 //defines the output mode, sets file permissionsint main(int argc, char *argv) //Define variablesint in_fd, out_fd //hold associated numbers on both filesint rd_size = 1 //hold amount of bytes in buffer (final should be 500)int wr_size //hold amount of bytes on the output filechar bufBUF_SIZE //initialise buffer and its sizeint rd_count = 0, buf_count = 0, wd_count = 0if (argc = 3) //check for correct number of argumentsprintf(Error Invalid number of parameters passed.)exit(1) //exit if too many or too few parametersin_fd = open(argv1, O_RDONLY) //open file to read from (read only)//if file isnt found, variable will have a negative numberif (in_fd printf(Error institutionalise not found.)exit(2) //exit if files emptyout_fd = creat(argv2, OUTPUT_MODE) //create the output file//if file isnt created, variable will have a negative numberif (out_fd printf(Error File not created.)exit(3) //exit if cannot write to the filewhile (rd_size 0) //while characters (in file) still existrd_size = read(in_fd, buf, BUF_SIZE) //read the file into bufferif (rd_size printf(Error Cant read from file.)exit(4) //exit if error while readingif (rd_size == 500) //if read,rd_count += 500buf_count += 1 //increment character and buffer counter elserd_count += rd_sizefor (int i=0 iif(bufi == )wd_count+=1 //increment if space foundwr_size = write(out_fd, buf, rd_size) //write from buffer into fileif (wr_size printf(Successfully written to filen)close(in_fd)close(out_fd) //close both filesprintf(Total number of characters read is %d.n, rd_count)printf(Total number of words %d.n, wd_count)printf(Buffer filled %d times.n, buf_count)exit(5)Impact of changing buffer sizeI neutered the buffer 3 times, the first was changing the size to 1000, the second was 1300 and the deuce-ace was 2000. What I noticed was as the buffer size increases, the amount of times the buffer is filled decreases as the buffer is able to fill in more characters each time. Below is a screen shot of when the buffer size was set to 2000We can see the buffer at this time was filled 0 times, meaning the entire text was placed into the buffer.Updated buffer.c code to compare if two files are the sameinclude //library for file control optionsinclude //library for general purpose toolsinclude //header fileinclude //file IOdefine BUF_SIZE 500 //sets buffer size to 500define OUTPUT_MODE 0700 //defines the output mode, sets file permissionsint main(int argc, char *argv) //Define variablesint in_fd, in_fd2 //hold associated numbers on both filesint rd_size = 1 //hold amount of bytes in buffer (final should be 500)int rd_size2 = 1char bufBUF_SIZE //initialise buffer and its sizechar buf2BUF_SIZE //initialise buffer and its size//int rd_count = 0, buf_count = 0, wd_count = 0if (argc = 3) //check for correct number of argumentsprintf(Error Invalid number of parameters passed.)exit(1) //exit if too many or too few parametersin_fd = open(argv1, O_RDONLY) //open first file to read fromif (in_fd printf(Error File not found.)exi t(2) //exit if files emptyin_fd2 = open(argv2, O_RDONLY) //open second file to read from//if file isnt found, variable will have a negative numberif (in_fd2 printf(Error File not found.)exit(3) //exit if files emptywhile (rd_size 0 rd_size2 0) //while characters (in file) still existrd_size = read(in_fd, buf, BUF_SIZE) //read file 1 to bufferrd_size2 = read(in_fd2, buf2, BUF_SIZE) //read file 2 to bufferif (rd_size printf(Error Cant read from file.)exit(4)for (int i=0 iif(bufi = buf2i) //if characters of the 2 files are not the sameprintf(The files are not the same)close(in_fd)close(in_fd2)exit(5) //print message and closeprintf(YESSSSSS The files are the same.) //if code passes the loop, theyre the sameComparison of review.txt and hamlet.txtComparison of hamlet.txt and review_observer.txtLab Activity 8 Cache BufferBrief Description of Cache Buffer ActivityThis weeks task was to alter the cache_reader.c file and complete the cr_read_byte function. Additionally, we also had to ad d a count of the total number of bytes and the number of times the buffer was filled.Commented implementation of the cr_read_byte functionchar cr_read_byte(cr_file* f)/* 1. check if buffer needs refilling2. return currently pointed character3. move pointer to next character */if(f-usedbuffer = f-bufferlength)refill(f)char currentChar = f-bufferf-usedbufferf-usedbuffer++return currentCharComment updated code to show that each byte is being read, and when the buffer is being refilled.To show that the buffer is being refilled, I added a print statement each time the buffer refills in the cr_read_byte() function. Also the next part of the inquiry will show that the buffer is being refilled and the bytes are being read by keeping a count each time that happens.*The code for this part of the question is combined with the next part (cache_reader.c).(I set the buffer to 200)Commented updated code showing to show how many bytes were read in total, and how many times the buffer was refilledI n this part, I had to update the code in 3 different files, below are the screenshots of every update I madecache_reader.hIn this sec

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.