Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the knowledge points related to learning Python operating system?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what are the knowledge points related to learning Python operating system". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

What is a time slice?

A time slice is a small amount of CPU time (5ms-800ms on Linux) allocated by a time-sharing operating system to each running process.

What is multi-level feedback?

Multi-level feedback is the operating system scheduling process, thread running order mechanism. The multi-level feedback queue scheduling algorithm can not only make the high priority jobs get response, but also make the short jobs finish quickly.

What is the difference between concurrent and parallel?

Concurrency: Multiple threads take turns preempting CPU time slices.

Parallel: Multiple threads running simultaneously on different CPUs.

Concurrency is essentially a single-threaded operation, python because the mechanism of GIL lock causes the process not to be parallel, only concurrent.

Python programs can only be concurrent and cannot be parallel. Why do concurrent programs sometimes greatly improve program execution efficiency?

Because python program single process execution will still compete with other processes of the operating system CPU, when python program encounters a lot of IO operation multi-thread concurrent execution, it takes up more CPU total time slice, so the running efficiency has been improved!

When to use concurrency and when not to use concurrency?

Assuming that some tasks involve a large number of IO(input and output) operations, then concurrency should be used. Assuming that those tasks do not involve IO operations, do not use concurrency. Concurrency that does not involve IO will reduce the overall running speed.

How to distinguish whether there is an IO operation involved?

The easy way to tell is to determine whether data has been in memory or whether there has been a flow between memory and peripherals. The data is always in memory! No IO operations involved! Data is transferred from peripherals to memory: such as reading hard disks, receiving data from network cards, receiving keyboard and mouse signals, receiving camera microphone signals, etc. These are inputs. Data is transferred from memory to peripherals: such as to network cards, hard disks, monitors, printers, etc. These are output.

Why distinguish between IO and non-IO?

Because data is read and written very, very fast in memory, read and write speeds in peripherals are very slow (some fast, some slow, overall several orders of magnitude slower than memory). Therefore, when it involves IO operations, it will cause the program to suspend execution, waiting for the IO device to report the result, and the program to suspend execution waiting for the IO device state is called blocking.

What program runs in three states?

Ready: The state in which a process is ready to wait for the operating system to give it a CPU time slice.

Execution: The state in which a process is running, allocated CPU time slices by the operating system. If the time slice runs out, the process immediately goes into a ready state. If the process involves an IO operation, it immediately enters a blocked state while waiting for a peripheral to respond.

Block: The process will immediately enter the block state when it encounters situations such as requesting a peripheral to wait for a peripheral to respond, waiting for a peripheral to complete a task, etc. When the process IO operation needs to continue to execute after completion, it can only enter the ready state first, and cannot be executed immediately.

Why does Python programs have to have if name='main' when running a function in multiple processes, while Linux and mac systems don't?

Because when multiple processes run a function under window, window will open up a memory space to import the file to which the function belongs. Note that import essentially runs once, and the specified function will be executed during import. Linux and mac under the multi-process running a function system will open up a memory space to copy all the contents of the parent process memory space, note that here only copy, not run! After copying, only the specified function is executed. The differences in operating system mechanisms lead to a much lower efficiency of multi-process running on window platforms than Linux and Mac. So many Python programmers love Linux and Mac.

"What are the knowledge points related to learning Python operating system" is introduced here. Thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report