python 38 assignment

Homework today

  • Brief history of operating system development

    Manual stage: paper tape technology

    Single-channel batch processing system: single-channel input, serial batch processing

    Multi-channel batch processing system: multi-channel input, batch processing

    Time-sharing operating system: divide time into smaller units and allocate time for processing

    Real-time operating system: weight different tasks and give priority to high weights

    Other operating systems: distributed, networked, personal computer operating systems

  • Briefly describe the process development history and algorithm evolution

    First come first serve

    First service of time period

    Time slice round forwarding + multi-level feedback queue

  • Brief description of multi-channel technology

    When a task occupies the CPU, the input and output devices will not be idle, preparing for the next task to run

  • Briefly introduce the concept of synchronous asynchronous blocking non-blocking

    Synchronization: After sending a request to a program, keep waiting for the result

    Asynchronous: After sending a request to a program, it will not wait forever, triggering the information feedback mechanism when there is a result

    Blocking: Due to the Io operation, the CPU will process other programs.

    Non-blocking: in ready or running state

  • Two ways of writing process creation

    #  方式一:直接调用函数
    from multiprocessing import Process
    import time
    
    
    def task(name):
        print(f'子进程{name}开始')
        time.sleep(3)
        print(f'子进程运行{name}结束')
    
    
    if __name__ == '__main__':
        #  Process是一个类,调用类生成对象p,需要传参
        print(f'主进程开始')
        p=Process(target=task, args=('1',))
        #  所有容器类型哪怕只有一个参数后面也要加逗号,防止是元组
        p.start()
        print(f'主进程结束')
    
    #  方式2:类的继承
    
    
    class MyProcess(Process):
        def __init__(self,name):
            super().__init__()
            self.name=name
    
        def run(self):
            print(f'子进程{self.name}开始')
            time.sleep(3)
            print(f'子进程{self.name}运行结束')
    
    
    if __name__ == '__main__':
        print(f'主进程开始')
        p = MyProcess('1')
        p.start()
        print(f'主进程结束')
    

Guess you like

Origin www.cnblogs.com/Franciszw/p/12753709.html
38
Recommended