Week 2 Assignmentcpt304

docx

School

Ashford University *

*We aren’t endorsed by this school

Course

304

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

4

Uploaded by ss08923

Report
1 Week 2 Assignment: Single vs Mutli-Threading Shyneece Smith CPT 304: Operating Systems Theory & Design November 26,2023
2 A single-threaded solution would be most effective for a printer performing the job of printing a set of documents. A single-threaded process is when the CPU executes one instruction after another, sequentially, until the process is complete (Silberschatz, 2014, p. 1.7). Since the printer is printing one page at a time and presumably having the pages printed in order is important, a single-threaded process would be well suited for this scenario. An application that allows the graphical user interface (GUI) to remain responsive while processing a large number of files.An application that allows the graphical user interface to remain responsive while processing files would work best with a multi-threaded solution. In a multi-threaded system, multiple tasks can be accomplished in parallel. According to Silberschatz (2014), "Several threads operate in the kernel, and each thread performs a specific task, such as managing devices, managing memory, or interrupt handling." (p. 4.1). In this scenario, since multiple tasks need to be executed in parallel, i.e., GUI must remain responsive while processing many files, a multi-threaded solution would be necessary. One thread would be responsible for processing files, while another thread would monitor the GUI for a new request. A Python webserver that listens for requests, reads them, and pushes the data in the database. Like the first scenario, a Python web server that listens for requests reads them, and pushes the data in the database, would work best with a single-threaded solution. Since the webserver is executing tasks sequentially, and each task is dependent on the previous one, multiple threads wouldn't be necessary. However, the system could also work with a multi-threaded system if numerous requests were coming in at the same time. One thread could listen to new requests while another would process previous requests into the database.
3 A shell program that closely monitors its own working space, such as open files, environment variables, and current working directory. A single-threaded solution would be most effective for a shell program that monitors its own working space. Since the shell program needs to monitor things carefully, the fewer threads operating will result in a more controlled environment; each thread represents a separate flow of control (Murali, 2021). A program that calculates a large number of payments where each calculation is independent of other payment calculations. This scenario would benefit most from a multi-threaded solution. Since a large number of payments need to be calculated, waiting for each calculation to be done sequentially, one after another, would be way too time-consuming. Having multiple threads would allow numerous calculations to be completed at the same time. Any program that is meant to run sequentially would work best with a single- threaded process (Murali, 2021). An example of this would be tax software. In this case, data would need to be entered sequentially and calculations would have to be made once all of the information is entered. An example where a multi-threaded process is most effective is Microsoft Word, or any other word processing software. Multiple threads in this case would handle all of the different tasks that need to be accomplished to have a successful word processor. One thread listens to user inputs and displays it on screen, and another thread checks for spelling and grammar errors (Murali, 2021). Certain scenarios may work well with either a single or multi-threaded process, like the first example of the printer. It may very well work efficiently with a single- threaded process, printing one page at a time. However, this process could be optimized through multi-threading. If there were several printers, a multi-threading process could expedite the whole operation.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
4 References Murali, M. (2021, March 14). Threads and Asynchronous Programming. DEV Community. https://dev.to/_mohanmurali/threads-and-asynchronous-programming-2j6e Silberschatz, A., Galvin, P. B., & Gagne, G. (2014). Operating system concepts essentials (2 nd ed.). Retrieved from https://redshelf.com