• Day 25 Concurrent Programming in Python


    Day 25 Concurrent Programming in Python

    What is concurrency并发?

    Concurrency is working on multiple things at the same time. In Python, this can be done in several ways: With threading, by letting multiple threads take turns.多线程 By firing off a task and continuing to do other stuff, instead of waiting for an answer from the network or disk. This is how asynchronous/eɪˈsɪŋkrənəs/异步的 IO operates with the asyncio/æˈsɪŋk/ 异步library. With multiprocessing we’re using multiple processes. This way we can truly do more than one thing at a time using multiple processor cores. This is called parallelism/ˈpærəlelɪzəm/ 并行.

     

    The difference between threads线程 and processes进程

    A thread is an independent sequence序列 of execution, but it shares memory with all the other threads belonging to your program. A Python program has, by default, one main thread. You can create more of them and let Python switch between them. This switching happens so fast that it appears like they are running side by side at the same time.

    A process is also an independent sequence of execution. Unlike threads, a process has its own memory space that is not shared with other processes. A process can clone itself, creating two or more instances.

     

    When Is Concurrency Useful?

    Concurrency can make a big difference for two types of problems. These are generally called CPU-bound and I/O-bound.

    I/O-bound problems cause your program to slow down because it frequently must wait for input/output (I/O) from some external resource. They arise frequently when your program is working with things that are much slower than your CPU.

    On the flip side, there are classes of programs that do significant computation without talking to the network or accessing a file. These are the CPU-bound programs, because the resource limiting the speed of your program is the CPU, not the network or the file system.

     

    Timeline of the operating system

    1969

    Unix was brought to life on a spare DEC PDP-7 at AT&T Bell Labs. When AT&T decided to abandon the Multics (Multiplexed Information and Computing Service) operating system on its minicomputers, Ken Thompson and Dennis Ritchie cobbled together an operating system so they could continue to play a space travel game that Thompson had developed. A colleague gave the system a jokey name based on Multics -- UNICS, the Uniplexed Information and Computing Service, which morphed into UNIX or Unix.

    1976

    Intergalactic Digital Research's maverick brain Gary Kildall creates CP/M, a simple microcomputer operating system for simple microcomputers. It would be the model for command-line DOS variations for two decades.

    1977

    The godfather of open source is born when the Computer Systems Research Group at UC Berkeley releases a variant on Unix called the Berkeley Software Distribution. BSD will ultimately spawn alternatives to some commercial microcomputer operating systems -- and form the core of at least one major commercial operating system, Mac OS X.

    1981

    The IBM PC is born, and so are PC-DOS and its alter ego, MS-DOS.

    1983

    Free software advocate Richard Stallman announces the plan for GNU, a Unix-like operating system that contains no proprietary software. Twenty-six years later, GNU's official kernel, GNU Hurd, will still be incomplete.

    1989

    Four years after being "encouraged" to leave Apple and founding NeXT Inc., Steve Jobs takes his career to the next level with the release of NeXTStep. The new operating system builds a beautiful graphical layer on top of BSD, adds an object-oriented development tool kit, and secures Jobs' eventual return to Apple. He holds onto that capital X in NeXT so he can slap it on Apple's next operating system.

    1993

    Windows NT appears, and everyone assumes the NT stands for New Technology. Microsoft later denies this, but it can't deny that NT is the love child of its union with IBM, and half-brother to OS/2.

    1995

    Windows 95 appears, to great fanfare. It spawns a new line of Microsoft operating systems with one foot in the 32-bit world and another stuck in the mud with not-yet-obsolete 16-bit software. Who'd have thunk it that it would take six years to wave goodbye to all that? But Windows 98, 1999's 98 Second Edition, and 2000's Windows Me had to pass before Windows could move on.

    1996

    The arrival of Macintosh System 7.6 heralds a new name -- Mac OS -- and a new game called Waiting for Copland. In the end, we abandon the wait for Copland when Apple buys NeXT and adapts its operating system instead.

    2001

    Apple abandons its old OS core and introduces Mac OS X. The X is the Roman numeral for 10, but some think it's a nod to X Window (which is in there) and the NeXT operating system (which is also in there). Either way, X marks the spot where Apple moved away from 1984 and into a brave new world.

    The Windows XP family is born. It begins with Windows XP, and increases every two years with a new -- but not necessarily a full -- release

  • 相关阅读:
    Win32汇编之其他指令
    Win32汇编过程与宏调用
    Win32汇编常用算数指令
    SQLi-LABS Page-1(Basic Challenges) Less1-Less4
    8 Best DDoS Attack Tools (Free DDoS Tool Of The Year 2019)
    4. 移动安全渗透测试-(Android逆向基础)
    3. 移动安全渗透测试-(Android基础漏洞)
    2. 移动安全渗透测试-(Android安全基础)
    1. 移动安全渗透测试-(环境搭建)
    Hacking/Penetrating tester bookmark collection
  • 原文地址:https://www.cnblogs.com/fengshili666/p/14298531.html
Copyright © 2020-2023  润新知