issue190:c_c
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue190:c_c [2023/02/26 12:05] – créée auntiee | issue190:c_c [2023/02/28 11:53] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | I was observing – not participating in – a discussion on shells and realizing there is a large gap in what a shell is, where it fits in, and what the perception is thereof. This issue, I want to explain the difference between the kernel and a shell. Imagine a three-layer cake. The bottom layer is your kernel, the middle layer is your shell, and the top layer is your application layer. The kernel is all about handling hardware. When I say handling hardware, what I mean is that it allocates memory or it handles input & output, say to your disk. In other words, it manages stuff. Something needs CPU time, the kernel will schedule that. All the security and protection also happens here, within the kernel. So, when a system call happens, it is what responds to that system call. This may not be of interest to you, but to understand what a system call is, think of it this way – when you ‘call’ the system to send a packet over the network, or ‘call’ the system to read a file from disk, or call the system to do some task for us, that is a system call. I don’t know how this makes sense to a native English speaker, but to me it made no sense at first, but instead of thinking of your mother calling you to come inside, think of it more of a telephone call where you order some sand to be delivered at your home, so you can mix cement to build a wall. | + | **I was observing – not participating in – a discussion on shells and realizing there is a large gap in what a shell is, where it fits in, and what the perception is thereof. This issue, I want to explain the difference between the kernel and a shell. Imagine a three-layer cake. The bottom layer is your kernel, the middle layer is your shell, and the top layer is your application layer. The kernel is all about handling hardware. When I say handling hardware, what I mean is that it allocates memory or it handles input & output, say to your disk. In other words, it manages stuff. Something needs CPU time, the kernel will schedule that. All the security and protection also happens here, within the kernel. So, when a system call happens, it is what responds to that system call. This may not be of interest to you, but to understand what a system call is, think of it this way – when you ‘call’ the system to send a packet over the network, or ‘call’ the system to read a file from disk, or call the system to do some task for us, that is a system call. I don’t know how this makes sense to a native English speaker, but to me it made no sense at first, but instead of thinking of your mother calling you to come inside, think of it more of a telephone call where you order some sand to be delivered at your home, so you can mix cement to build a wall.** |
- | The shell is an interface between the user and the system and the kernel is an interface between system calls and the actual hardware. | + | J’observais – je n’y participais pas – une discussion sur les shells et je me rendais compte du fait qu’il y a un grand écart entre ce qu’est un shell, où il se place et la perception qu’en ont les gens. Dans ce numéro-ci, je veux expliquer la différence entre le noyau et un shell. Imaginez un gâteau qui a trois niveau. Le niveau du bas est le noyau, le niveau du milieu est le shell et le niveau du haut est celui des applications. Le noyau gère le matériel. Quand je dis cela, je veux dire qu’il répartit la mémoire ou qu’il gère les entrées et les sorties, disons de et vers votre disque. Autrement dit, il gère des trucs. Un truc a besoin d'un peu de temps du processeur et le noyau planifiera ce qui est nécessaire. Toute la sécurité et la protection a lieu à l’intérieur du noyau aussi. Ainsi, quand un appel système a lieu, c’est le noyau qui y répond. Cela peut ne pas vous intéresser, |
+ | |||
+ | **The shell is an interface between the user and the system and the kernel is an interface between system calls and the actual hardware. | ||
You may also hear people talking about ‘spaces’ – kernel space and user space. This simply groups things together into the ‘space’ where they ‘live’. VLC player and Inkscape are applications that live in user space. You, as the user, interact with them. You do not get to do things in the kernel space. For instance, the memory manager lives in the kernel space and it allocates memory for VLC or Inkscape, but you do not get to interact with it. Think of it as a lunch counter. You can order food here, the person behind the counter (the system call interface) takes your order and passes it on to the kitchen (the kernel), and out pops your food. You do not get to interact with the stove or the ingredients, | You may also hear people talking about ‘spaces’ – kernel space and user space. This simply groups things together into the ‘space’ where they ‘live’. VLC player and Inkscape are applications that live in user space. You, as the user, interact with them. You do not get to do things in the kernel space. For instance, the memory manager lives in the kernel space and it allocates memory for VLC or Inkscape, but you do not get to interact with it. Think of it as a lunch counter. You can order food here, the person behind the counter (the system call interface) takes your order and passes it on to the kitchen (the kernel), and out pops your food. You do not get to interact with the stove or the ingredients, | ||
- | We can see how long a command spends in each by using the ‘time’ command on the command-line. Type: time ls | + | We can see how long a command spends in each by using the ‘time’ command on the command-line. Type: time ls** |
- | Look at the output, does it make sense to you? | + | Le shell est une interface entre l’utilisateur et le système ; le noyau est une interface entre les appels système et le matériel. |
+ | |||
+ | Vous pouvez aussi entendre parler d’« espaces » - espace noyau et espace utilisateur. Cela ne fait que regrouper les trucs ensemble dans l’« espace » où ils « vivent ». Le lecteur VLC et Inkscape sont des applications qui vivent dans l’espace utilisateur. Vous, en tant qu’utilisateur, | ||
+ | |||
+ | Nous pouvons voir combien de temps une commande passe dans chacun des espaces en utilisant la commande « time » dans le terminal. Tapez : time ls | ||
+ | |||
+ | **Look at the output, does it make sense to you? | ||
You will see: | You will see: | ||
Ligne 20: | Ligne 28: | ||
Let us do something a little more intensive to get values all around. If you have a directory with stuff in it, (no use on an empty one!), type: time md5sum * | Let us do something a little more intensive to get values all around. If you have a directory with stuff in it, (no use on an empty one!), type: time md5sum * | ||
- | This simply prints out the MD5 hash of the file, before printing out the file name. If you don’t know what a MD5 hash is, ask. | + | This simply prints out the MD5 hash of the file, before printing out the file name. If you don’t know what a MD5 hash is, ask.** |
- | This can be a crude indication of where your command or program spends its time. Go ahead, try it with, say, Python (shown below) or whatever program you wish. | + | Regardez la sortie. Est-ce qu’elle vous semble logique ? |
+ | |||
+ | Vous verrez : | ||
+ | •• « real », | ||
+ | •• « user », | ||
+ | •• « sys », | ||
+ | |||
+ | Oui, je sais, mais restez avec moi, ma cible, ce sont les vrais débutants. | ||
+ | |||
+ | (J’ai découvert pourquoi j’ai dû refaire les semaines 47 et 48 l’année dernière... c’était évident.) | ||
+ | |||
+ | Faisons quelque chose d'un peu plus intensif pour avoir des valeurs partout. Si vous avez un répertoire avec des trucs dedans (inutile sur un répertoire vide !), tapez : time md5sum * | ||
+ | |||
+ | Cela ne fait qu’imprimer le hash MD5 du fichier, avant d’imprimer le nom du fichier. Si vous ne savez pas ce qu’est un hash MD5, demandez. | ||
+ | |||
+ | **This can be a crude indication of where your command or program spends its time. Go ahead, try it with, say, Python (shown below) or whatever program you wish. | ||
We used our terminal emulator (an application living in user space) to use the shell, in my case bash, to do something (make a system call). | We used our terminal emulator (an application living in user space) to use the shell, in my case bash, to do something (make a system call). | ||
Ligne 28: | Ligne 51: | ||
The kernel allocated memory, handled the i/o for writing that file to disk, etc, and the ordered python program popped out, just like our hot dog example. You did not get to interact with the i/o interface, the memory manager, or the process manager, but you got your Python program. The Python program was my wall, the command I used in my shell (bash) made a system call to write a file to disk (a telephone call to order sand) – is this coming together for you yet? No? Play a *quick game of Sins of a solar empire, and come back. | The kernel allocated memory, handled the i/o for writing that file to disk, etc, and the ordered python program popped out, just like our hot dog example. You did not get to interact with the i/o interface, the memory manager, or the process manager, but you got your Python program. The Python program was my wall, the command I used in my shell (bash) made a system call to write a file to disk (a telephone call to order sand) – is this coming together for you yet? No? Play a *quick game of Sins of a solar empire, and come back. | ||
- | That’s as short ‘n sweet as I can make it (with my brain running in a million directions, whilst I try to herd those 100 cats). If you still have trouble understanding what a shell is, and where it fits in with regards to the kernel, read that again. Just kidding, drop us a line on: misc@fullcirclemagazine.org | + | That’s as short ‘n sweet as I can make it (with my brain running in a million directions, whilst I try to herd those 100 cats). If you still have trouble understanding what a shell is, and where it fits in with regards to the kernel, read that again. Just kidding, drop us a line on: misc@fullcirclemagazine.org** |
+ | |||
+ | Cela peut donner une indication approximative de l’endroit où votre commande ou programme passe son temps. Allez-y, essayez avec, disons, Python (voir ci-dessous) ou le programme que vous voulez. | ||
+ | |||
+ | Nous avons utilisé notre émulateur de terminal (une application qui vit dans l’espace utilisateur) pour utiliser le shell, dans mon cas bash, pour faire quelque chose (un appel système). | ||
+ | |||
+ | Le noyau a alloué de la mémoire, géré les entrées/ | ||
+ | |||
+ | C’est aussi précis et concis que possible pour moi (avec le cerveau qui court dans des milliers de directions pendant que j’essaie de rassembler les cent chats). Si vous ne voyez toujours pas ce qu’est un shell et sa place par rapport au noyau, relisez l’article. Je plaisante, écrivez-nous sur : | ||
issue190/c_c.1677409556.txt.gz · Dernière modification : 2023/02/26 12:05 de auntiee