Question

In: Computer Science

Task: there are mainly five types of system calls: Process Control, File Management, Device Management, Information...

Task: there are mainly five types of system calls: Process Control, File Management, Device
Management, Information Maintenance and Communication. Please write two python programs
to implement the above two types of system calls.

Solutions

Expert Solution

Lets us first look at some terms that will help us understand system calls better and how they are executed.

Kernel - The kernel is the heart of a computer's operating system. It is in charge of everything that a computer executes such as processes, files, display, memory management, etc.

A System call is a call to the kernel to signal it for a service or a resource. System calls are of many types like process, file, information, communication, and device.

Process Control - Process control refers to the procedure of creating, handling, and terminating a process by a system call to the kernel.

Process control is implemented in python by a package called the OS which has access privileges to communicate with the kernel itself and fork new child process from parent processes. Either we can use the os.fork() to fork a child process from the parent OS process itself or use a package called multiprocessing to create multiple child processes.

Let's look at a code implementation in python. The code is commented for better understanding.

import os 
# multiprocessing package
import multiprocessing 
  
# function process to depict process management
def process(): 
    # printing process id 
    print("ID of child process: {}".format(os.getpid())) 


#test function in main 
if __name__ == "__main__": 

    # parent process id
    print("ID of main process: {}".format(os.getpid())) 
  
    # creating child processes 
    child = multiprocessing.Process(target=process) 
    child_2 =  multiprocessing.Process(target=process)
    child_3 =  multiprocessing.Process(target=process)  

    # starting child processes 
    child.start() 
    child_2.start() 
    child_3.start() 

    #child process IDs 
    print("ID of child process : {}".format(child.pid)) 
    print("ID of child_2 process : {}".format(child_2.pid)) 
    print("ID of child_3 process : {}".format(child_3.pid)) 
  
    # wait until processes are finished 
    child.join() 
    child_2.join()
    child_3.join()
  

(2)

A File management system call to the kernel is used to open, read, create and modify files. Files management is an integral part of any operating system.

Let's implement a basic file management code in python that opens a file, modify it and writes to a new file by creating another file.


#open a file in read mode
file = open('cars.txt','r')

#for each line in file read
for lines in file:
    print(lines)

#open a new file in read/write/create mode
new_file = open('new_file.txt','x')

#write to the new file
new_file.write("bye")

#close the file
file.close()





Related Solutions

What are System calls. Provide 6 file and directory system calls
What are System calls. Provide 6 file and directory system calls
Capstone Course: Cases in Health Care Management System control Reflect on five elements of system control,...
Capstone Course: Cases in Health Care Management System control Reflect on five elements of system control, and how they have been applied in your workplace(s). A system of control comprises five elements: In a 3-page essay, answer the following questions: 1-List and describe five elements of system control. 2-What happens if one of these systems is skipped or not specifically addressed? 3-Provide evidence from personal examples. As a healthcare manager, how will you ensure these issues are addressed? Please list...
File management is the process of administering a system that correctly handles digital data. Therefore, an...
File management is the process of administering a system that correctly handles digital data. Therefore, an effective file management system improves the overall function of a business workflow. It also organizes important data and provides a searchable database for quick retrieval. Now that you have more insight into file management, how will you use file management with your computer? Why is fie management necessary? How would file management help you to be more efficient?
1. Name the three types of MIS (Management Information System) for each level of management and...
1. Name the three types of MIS (Management Information System) for each level of management and describe one of them in detail 2. Which type of MIS uses the Balanced Score Card for reporting organizational performance a. Management Reporting System (MRS) b. Transaction Processing System (TPS) c. Executive Support System (ESS) 3. A software system to bill customers for the goods purchased at a retail store a. Management Reporting System (MRS) b. Transaction Processing System (TPS) c. Executive Support System...
Develop a simple MIS (Management Information System) that consists of a simple database (a text file)....
Develop a simple MIS (Management Information System) that consists of a simple database (a text file). The system manages to dynamically input record/data into the database. The data from the database can be sorted, searched and updated. User also should be able to add new records/data, remove any data and etc. Here are some ideas of MIS that can be developed: 1. Hotel reservation system. 2. Students management system. 3. Payroll management system. 4. Bus/Railway/Plane ticketing system. 5. Clinic record...
control system Design a system that will run on a PID process
control system Design a system that will run on a PID process
WOM plc uses budgetary control as part of their Management Information System. As the Finance Director...
WOM plc uses budgetary control as part of their Management Information System. As the Finance Director at WOM plc, you are required to give a verbal presentation to graduate trainees entitled ‘The importance of budgetary control’. Prepare the speech you would give as part of the presentation in which you demonstrate an understanding of the underpinning concepts and ideas of budgetary control within large companies. You must use examples to support your explanation
There are five different types of control methods that managers can utilize to maintain control. These...
There are five different types of control methods that managers can utilize to maintain control. These are bureaucratic, concertive, objective, normative and self-control (self-management). Please compare and contrast the different types of control methods. Please describe which method you think is the most effective and which one is the least effective. Which method would you prefer to use as a manager? Does this differ from which method you would like to work under as an employee?
Use the following information for the next five exercises. Two types of phone operating system are...
Use the following information for the next five exercises. Two types of phone operating system are being tested to determine if there is a difference in the proportions of system failures (crashes). Fifteen out of a random sample of 150 phones with OS1 had system failures within the first eight hours of operation. Nine out of another random sample of 150 phones with OS2 had system failures within the first eight hours of operation. OS2 is believed to be more...
The Five Management Functions as a Coordinated System. Of the five management functions, which do you...
The Five Management Functions as a Coordinated System. Of the five management functions, which do you expect will experience the most dramatic changes in the next decade? Defend your answer. Which will have the least amount of change? Explain your answer.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT