oo second summary

 The fifth assignment--summary and analysis of multi-thread elevator

  1. Policy analysis

   Due to the previous two elevator experiences, although the difficulty was increased this time, I was more confident when I wrote it myself. Since this time the multi-threaded elevator is running, in order to simulate the actual operation situation, I gave up this time. Based on the previous two queue ideas, the method of simulating time is adopted, and there are three elevator threads, one general scheduling thread, and one input thread. Because multiple threads are running at the same time, and the input thread and the scheduling thread share a request tray. Each elevator and dispatcher shares its own executing sequence of instructions. Therefore, the total instruction sequence and the own running sequence of each elevator are used as locks, and the code blocks that may cause conflicts are separately locked to achieve thread synchronization.

      2. Overview of class diagrams

     

 

 

   3. Quantitative analysis

   

 

   4. BUG analysis

   The bug in the program this time really made me cry. DOWN was spelled as DOWN. When outputting invalid instructions, I forgot to output the time. When outputting the running time of each elevator, an extra line feed was added to an inexplicable output position. These errors are suffocating, and I am very grateful to my classmates for helping me find these small problems. The program idea is well designed, the core is written, but not really finished, and it is also essential to be able to output according to the given standard.

 

 The sixth homework - file system

  1. Strategy analysis   

   I was very happy when I saw this topic, because I finally didn't have to write about the elevator. I discussed this assignment with my roommate for one night and found that this assignment is still very simple. Compared with the last elevator, it only needs to be done every other day. Scan the file directory, two for loops, two arrays, the newly scanned file array, and the last scanned file array in 500ms, and compare the two information according to the pressure ball in the instruction book to determine whether there is any Triggered, because the program itself is scanning, only the operation of reading, so it is thread-safe, and this time I learned some format methods and string splicing of the String class with my roommate, and there will be no thread runtime output. Interspersed phenomenon. So this time the program is thread-safe, so it is easier to write, and the test of the running effect is more correct.  

  2. Overview of class diagrams

      

  3. Quantitative analysis

      

   It seems that the influence of C language on me still exists. A function always wants to have more functions, which leads to imbalance. Try to correct it later.

  4. Bug analysis

  Due to inexplicable reasons, this homework was invalidated. I am very sorry. I don’t know if I have more bugs, but I know that I have a bug, because when I designed it, it was a request for a thread, so When a file is simultaneously monitored for size, name, path, and trigger, it is restored, written to summary, and written to detail. The result will be unpredictable due to thread problems, but it can be reasonably explained. The others have not yet been discovered.

 The seventh assignment - taxi problem_1

  1. Strategy analysis

   When I saw this assignment, my first reaction was 100 elevators? ? ? (The child who was poisoned too deeply by the elevator), but after careful thinking, I found that this work is indeed somewhat similar to the elevator, so the design idea was immediately created, request thread, taxi thread, input thread. As soon as the request thread starts, it sleeps for 3000ms, and asks the taxi to grab the order, and the taxi grabbed by the order is requested to be screened after 3000ms. Since the taxi needs to scan the request queue, and the input needs to add requests, the request queue is locked to the scan of the taxi and the read of the input thread. Since the state of the taxi needs to be changed when requesting to select a taxi, whichever taxi is selected will be used as the lock to lock the part that modifies the state. In order to facilitate the synchronization of threads and ensure thread safety.

  2. Overview of class diagrams

  

 

 3.  Quantitative analysis

       

 

  4. Bug analysis

  I was surprised that the bug was not found this time, because the OS mid-term exam was scheduled last week, so it was indeed a bit hasty to write my own program to review this time, but the basic commands can still be run. I output the running track in a separate file. Although there are more than 100 files, it still looks very clear.

experience and experience

  Through the writing and testing of these three assignments, I became more and more bearish on the results of this course, and only wanted to train my skills from this course. Grades do not absolutely reflect how well you have learned this course, as long as you learn what you want to learn.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325163542&siteId=291194637