Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the queue in Python

Shulou Source: shulou.com Published: 2022-06-02 05:29:24 09月16日 Update

This article mainly introduces "what is the queue in Python". In the daily operation, I believe that many people have doubts about what the queue in Python is. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the question of "what is the queue in Python?" Next, please follow the editor to study!

What is a queue?

A queue is an ordered collection of data

The addition of new data items always occurs at one end-the removal of existing data items at the end of the line (rear) always occurs at the other end-the head of the line (front)

Queue rule: first-in, first-out FIFO (First In First Out), first-in data, first-out

The queue has only one entry and one exit, and data items are not allowed to be inserted directly into the queue or deleted from the middle.

Queue example 1: print queue for printer

Queue example 2: process scheduling

The kernel of the operating system uses multiple queues to schedule processes running simultaneously.

Add:

A piece of code that does not run-- the program

A piece of running code-- process

The process consists of many threads

The purpose of the process is to realize the concurrency of the program

The kernel of CPU uses queues to schedule processes (running code), and the more kernels you have, the better the performance of CPU. When the wrong order of processes leads to a dead loop in resource allocation, a process deadlock occurs

Process scheduling features:

The more processes there are than the number of CPU cores (so process scheduling is required)

Some processes also have to wait for different types of IZP O events (speed of IZP O events)

Tags: Queues processes data scheduling data items examples kernel speed learning running events code complexity one end elements functions principles complexity time more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple Shulou Tech Info vpn Microsoft