12.1 (Conspect) High-level languages and OS

systemd is a main dbus 'follower/consumer'. busctl can show the tree and the introspection looks normal.

The Linux kernel is written in C (because the programming language is macro-assembler):

Also a shell appears not as written but as a gluing(linking) of programs to C++ - for specific libraries and system actions (batch manager)

The list that represents information about Linux: Linux:

⇒ Is C the only system programming languages?

Windows:

MacOS:

The main language of linking is shell, after all. But sometimes there's already a python.

We see that there's a C language everywhere, and there is a C language. a universal system programming language? Yes and no!

Recently, the Rust language has been gaining popularity (C language killer) RUST

Python and OS programming

Any other programming language is suitable for writing system programs with a remark: when we write in C, the fact that the computational model provided to you by the language is extremely close to the hardware on which you program. It makes you treat programming as if it were a stack, registers, allocated memory, heap, call agreements. We have an idea how these bytes are spent, especially important for cores. As soon as we start programming in a high-level language - this thought will disappear (how much and what resources are taken away we don't understand) - we stop thinking like a system programmer, we can make a small utility that eats a lot of memory.

Python: * Cross-platformness (if you look at standard python modules, in some cases they are marked as unix/windows specificity)

Example:

   1 import os
   2 import sys
   3 os.getcwd()

* POSIX-oriented (=> Linux)

* High-level, but not OS-oriented (unlike shell)

* Non «resource scrimp» style

If you run one of these from windows, there's a whole other way.

OS AND SYS

The os module provides many functions to work with the operating system, and their behavior is usually independent of the OS, so programs remain portable. Here you will find the most commonly used ones.

The sys module provides access to some variables and functions that interact with the python interpreter.

Subprocess

Allows you to start the process. Concept: cross-platform process execution with communication and exit status control.

   1 import subprocess as proc
   2 proc.run(["ls",  "-al", "/tmp"])

Called the process ls, with parameters.

   1 Res = proc.run([‘ls’,  ‘-al’, ‘/tmp’])
   2 print(Res)

Popen

* High-level popen analog: Popen()

Treads

In Python, the trades work "synchronously" (read: not working) due to GIL (global interpreter lock)

The threading module can be used if:

Multitasking

Cross-platform module multiprocessing

HSE/ArchitectureOS/12_HighLevelLanguages/Conspect_en (последним исправлял пользователь NataliaKrauze 2020-06-02 21:37:59)