issue107:tutoriel1
                Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| issue107:tutoriel1 [2016/04/14 10:37] – auntiee | issue107:tutoriel1 [2016/04/15 07:25] (Version actuelle) – d52fr | ||
|---|---|---|---|
| Ligne 5: | Ligne 5: | ||
| To understand logicals, I have to explain the philosophy behind the file-system of VMS. In Linux there is one “device” ('/' | To understand logicals, I have to explain the philosophy behind the file-system of VMS. In Linux there is one “device” ('/' | ||
| - | Au début des ordinateurs, | + | Au début des ordinateurs, | 
| La philosophie du système de fichiers ? | La philosophie du système de fichiers ? | ||
| - | Pour comprendre les « logicals », je dois vous expliquer la philosophie derrière le système de fichiers de VMS. Sous linux, il y a un « dispositif » ('/' | + | Pour comprendre les « logicals », je dois vous expliquer la philosophie derrière le système de fichiers de VMS. Sous linux, il y a un « dispositif » ('/' | 
| **As an example, this is how you would address a file in VMS: | **As an example, this is how you would address a file in VMS: | ||
| Ligne 33: | Ligne 33: | ||
| / | / | ||
| - | Remarquez les majuscules dans VMS et le numéro à la fin (la version du fichier, décrite dans la Partie | + | Remarquez les majuscules dans VMS et le numéro à la fin (la version du fichier, décrite dans la partie | 
| Que sont les logicals ? | Que sont les logicals ? | ||
| - | Un logical est une paire nom/ | + | Un logical est une paire nom/ | 
| - | Chaque fois que vous accéderez à un dispositif, le système regardera d' | + | |
| **This mechanism is very versatile. You can influence what device is accessed by changing the corresponding logical (give it another value), and the value can contain more information than just a device: it can also contain the path to a folder (directory), | **This mechanism is very versatile. You can influence what device is accessed by changing the corresponding logical (give it another value), and the value can contain more information than just a device: it can also contain the path to a folder (directory), | ||
| Ligne 46: | Ligne 45: | ||
| The value is not limited to one string. You are allowed to specify more than one string, separated by a comma to get a search list. If the system does not find the file in the folder resulting from the first “translation”, | The value is not limited to one string. You are allowed to specify more than one string, separated by a comma to get a search list. If the system does not find the file in the folder resulting from the first “translation”, | ||
| - | Ce mécanisme est très versatile. Vous pouvez modifier le dispositif auquel vous accédez en changeant le logical correspondant (lui onner une autre valeur), et la valeur peut contenir plus d' | + | Ce mécanisme est très souple. Vous pouvez modifier le dispositif auquel vous accédez en changeant le logical correspondant (lui donner | 
| Plus d'une traduction. | Plus d'une traduction. | ||
| - | La valeur n'est pas limitée à une seule chaîne. Vous pouvez spécifier plus d'une chaîne, séparée par une virgule pour avoir une liste de choses à rechercher. Si le système ne trouve pas le fichier dans le dossier qui résulte de la première « traduction », il continuera sa recherche en suivant la seconde « traduction », puis la troisième et ainsi de suite. Quoique très utile, soyez prévenu : cela peut avoir un effet secondaire désagréable. Si vous accédez à un fichier au moyen d'une liste de choses à rechercher, et que vous n'avez pas les droits pour accéder au fichier (il est protégé, son propriétaire est root, etc.) le système continuera sa recherche, mais ne le trouvera pas dans les autres dossiers. Puis il vous indique | + | La valeur n'est pas limitée à une seule chaîne. Vous pouvez spécifier plus d'une chaîne, séparée par une virgule pour avoir une liste de choses à rechercher. Si le système ne trouve pas le fichier dans le dossier qui résulte de la première « traduction », il continuera sa recherche en suivant la seconde « traduction », puis la troisième et ainsi de suite. Quoique très utile, soyez prévenu : cela peut avoir un effet secondaire désagréable. Si vous accédez à un fichier au moyen d'une liste de choses à rechercher et que vous n'avez pas les droits pour accéder au fichier (il est protégé, son propriétaire est root, etc.), le système continuera sa recherche, mais ne le trouvera pas dans les autres dossiers. Puis il vous indiquera | 
| - | In part 1, I mentioned that I have had bad experiences with frequent, but random, errors on Charon-VAX. These errors involved the translation of a logical which contained a search list. One in every hundred or so translations failed. It was impossible to find what was wrong, because the next time the same logical was translated, there was no error. It was because of the randomness of the error that we decided not to use Charon-VAX on our production computers, only the development computers were emulated. | + | **In part 1, I mentioned that I have had bad experiences with frequent, but random, errors on Charon-VAX. These errors involved the translation of a logical which contained a search list. One in every hundred or so translations failed. It was impossible to find what was wrong, because the next time the same logical was translated, there was no error. It was because of the randomness of the error that we decided not to use Charon-VAX on our production computers, only the development computers were emulated. | 
| - | **Not as simple as it sounds... | + | Not as simple as it sounds... | 
| The implementation of logicals in VMS is very complex: a logical is part of a table and there are many different tables. Which tables and the order in which the system looks for the logical is specified in yet another logical. I will not try to explain all of this – it would be outside the scope of this article. Let me only mention that the most used tables are process, job (session), group (GID) and system tables, and they are searched in that order. This makes it possible to create a pointer to a folder for your group in the group table, and temporarily create the same pointer to a different folder for test purposes in your job or process table for your own use - without disturbing the other users or services, as would be the case when using hard links. | The implementation of logicals in VMS is very complex: a logical is part of a table and there are many different tables. Which tables and the order in which the system looks for the logical is specified in yet another logical. I will not try to explain all of this – it would be outside the scope of this article. Let me only mention that the most used tables are process, job (session), group (GID) and system tables, and they are searched in that order. This makes it possible to create a pointer to a folder for your group in the group table, and temporarily create the same pointer to a different folder for test purposes in your job or process table for your own use - without disturbing the other users or services, as would be the case when using hard links. | ||
| Ligne 65: | Ligne 64: | ||
| • In VMS, the logical “TT” points to the terminal you work on. This could be a physical terminal (TTAxxx), a network terminal using the LAT protocol (LTAxxx), a telnet terminal (TNAxxx), an Xterm terminal (FTAxxx), or a remote terminal using the DecNet protocol (RTAxxx). Your program does not need to know which device started the program; it just reads from and writes to “TT:” (note the colon, this signals that TT is a device, not a file). Do not confuse this with stdin and stdout. These are file handles and they open the file “TT: | • In VMS, the logical “TT” points to the terminal you work on. This could be a physical terminal (TTAxxx), a network terminal using the LAT protocol (LTAxxx), a telnet terminal (TNAxxx), an Xterm terminal (FTAxxx), or a remote terminal using the DecNet protocol (RTAxxx). Your program does not need to know which device started the program; it just reads from and writes to “TT:” (note the colon, this signals that TT is a device, not a file). Do not confuse this with stdin and stdout. These are file handles and they open the file “TT: | ||
| + | |||
| + | Dans la partie 1, je mentionné que j'ai eu de mauvaises expériences avec des erreurs fréquentes, | ||
| Pas aussi simple que ça en a l' | Pas aussi simple que ça en a l' | ||
| - | L' | + | L' | 
| Exemples d' | Exemples d' | ||
| - | Pour clarifier cet outil complexe, je donnerai quelques exemples de comment on utilise | + | Pour clarifier cet outil complexe, je donnerai quelques exemples de la manière d' | 
| • Dans Linux, le système se trouve sur « '/' | • Dans Linux, le système se trouve sur « '/' | ||
| - | • Dans VMS, le logical « TT » pointe vers le terminal sur lequel vous travaillez, que ce soit un terminal physique (TTAxxx), un terminal réseau utilisant le protocole LAT (LTAxxx), un terminal telnet (TNAxxx), un terminal Xterm (FTAxxx) ou un terminal à distance utilisant le protocole (RTAxxx). Votre programme n' | + | • Dans VMS, le logical « TT » pointe vers le terminal sur lequel vous travaillez, que ce soit un terminal physique (TTAxxx), un terminal réseau utilisant le protocole LAT (LTAxxx), un terminal telnet (TNAxxx), un terminal Xterm (FTAxxx) ou un terminal à distance utilisant le protocole (RTAxxx). Votre programme n' | 
| **• Suppose you made a process that reads files with file-type XML from 3 folders (placed there by 3 other process), and put the result in another. You could define 2 group logicals pointing to these folders: | **• Suppose you made a process that reads files with file-type XML from 3 folders (placed there by 3 other process), and put the result in another. You could define 2 group logicals pointing to these folders: | ||
| Ligne 94: | Ligne 95: | ||
| Now you can run the new process and test it by copying files to MYDISK0: | Now you can run the new process and test it by copying files to MYDISK0: | ||
| - | • Supposons que vous ayez créé un processus qui lit des fichiers de type XML dans trois dossiers (où ils ont été placés par trois autres processus), | + | • Supposons que vous ayez créé un processus qui lit des fichiers de type XML dans trois dossiers (où ils ont été placés par trois autres processus), | 
| define/ | define/ | ||
| Ligne 100: | Ligne 101: | ||
| define/ | define/ | ||
| - | Votre processus chercherait alors des entrées en utilisation | + | Votre processus chercherait alors des entrées en utilisant | 
| Mais vous avez modifié votre processus et voulez le tester. Lire des fichiers à partir de dossier(s) input pourrait perturber votre système ; vous définissez donc deux nouveaux logicals au niveau job : | Mais vous avez modifié votre processus et voulez le tester. Lire des fichiers à partir de dossier(s) input pourrait perturber votre système ; vous définissez donc deux nouveaux logicals au niveau job : | ||
| Ligne 108: | Ligne 109: | ||
| define/job OUTPUT_FOLDER MYDISK0: | define/job OUTPUT_FOLDER MYDISK0: | ||
| - | Vous pouvez maintenant exécuter le nouveau processus et le tester en copiant des fichiers sur MYDISK0: | + | Vous pouvez maintenant exécuter le nouveau processus et le tester en copiant des fichiers sur MYDISK0: | 
| ** • Suppose you measure the weight of your product with an old scale, and then you purchase a new scale. In the first few weeks, you want to be able to switch between the scales. You could have 2 different executables, | ** • Suppose you measure the weight of your product with an old scale, and then you purchase a new scale. In the first few weeks, you want to be able to switch between the scales. You could have 2 different executables, | ||
| Ligne 126: | Ligne 127: | ||
| To use version control, I create a new folder tree for every version and use a logical to specify which version is active. As an example: My current version is 7.2, so I create the folder APP$DISK: | To use version control, I create a new folder tree for every version and use a logical to specify which version is active. As an example: My current version is 7.2, so I create the folder APP$DISK: | ||
| - | • Supposons que vous mesurez le poids de votre produit avec une vieille balance (scale) et que vous achetez ensuite une nouvelle balance. Au cours des premières semaines, vous voudrez pouvoir basculer entre les balances. Vous pourriez avoir deux programmes exécutables et arrêtez | + | • Supposons que vous mesurez le poids de votre produit avec une vieille balance (scale) et que vous achetez ensuite une nouvelle balance. Au cours des premières semaines, vous voudrez pouvoir basculer entre les balances. Vous pourriez avoir deux programmes exécutables et arrêter | 
| new_scale := $TRNLNM (“NEW_SCALE”); | new_scale := $TRNLNM (“NEW_SCALE”); | ||
| Ligne 132: | Ligne 133: | ||
| if new_scale = ' | if new_scale = ' | ||
| - | Vous pourriez vous servir de la commande terminal | + | Vous pourriez vous servir de la commande terminal | 
| define/ | define/ | ||
| Ligne 138: | Ligne 139: | ||
| et, pour vous servir de la vieille balance : | et, pour vous servir de la vieille balance : | ||
| - | define/ | + | define/ | 
| - | Afin de pouvoir utiliser le contrôle de version, je crée une nouvelle arborescence de dossiers pour chaque version et j' | + | Afin de pouvoir utiliser le contrôle de version, je crée une nouvelle arborescence de dossiers pour chaque version et j' | 
| **The logical KW21 used as pointer to the current version is created with: | **The logical KW21 used as pointer to the current version is created with: | ||
| Ligne 158: | Ligne 159: | ||
| define/ | define/ | ||
| - | L' | + | L' | 
| - | Pour utiliser la version 7.3, je créerais APP$DISK: | + | Pour utiliser la version 7.3, je créerais APP$DISK: | 
| Le seul inconvénient de cette méthode est qu'il faut utiliser KW21: | Le seul inconvénient de cette méthode est qu'il faut utiliser KW21: | ||
| Ligne 172: | Ligne 173: | ||
| For the search list, you can use environment variables (PATH), but these are valid within only one process and cannot be changed by another process. Also not an option...** | For the search list, you can use environment variables (PATH), but these are valid within only one process and cannot be changed by another process. Also not an option...** | ||
| - | Comment gérer | + | Comment gérer | 
| - | J' | + | J' | 
| - | Pour la liste de recherche, vous pouvez utiliser des variables d' | + | Pour la liste de recherche, vous pouvez utiliser des variables d' | 
| **My solution | **My solution | ||
| Ligne 186: | Ligne 187: | ||
| Ma solution | Ma solution | ||
| - | Pour utiliser des logicals sous Linux, j'ai créé quelques procédures dans ma bibliothèque pour remplacer les fonctions de VMS pour définir, supprimer (« deassign | + | Pour utiliser des logicals sous Linux, j'ai créé quelques procédures dans ma bibliothèque pour remplacer les fonctions de VMS pour définir, supprimer (« dé-assigner | 
| - | Lors du démarrage d'un programme, les tables partagées (system, group et job) sont ouvertes - ou créées si nécessaire - et mappées dans la mémoire | + | Lors du démarrage d'un programme, les tables partagées (system, group et job) sont ouvertes - ou créées si nécessaire - et mappées dans la mémoire | 
| - | LNM_PROCESS is not a table. It's a logical pointing to another table containing the process ID (pid) in its name to separate the many process tables from each other. The behavior of Linux concerning process ID's is different from that of VMS (I will go into more detail on this in part 5 about DCL). DCL (Digital Command Language) is a real shell: it wraps around a process, and every time an executable (“image” in VMS) is started, it runs within this shell, within the same memory, with the same logicals and symbols (environment variables) and with the same process ID. Bash is called a shell, but it is NOT! It is a CLI (Command Line Interpreter). Every time an executable is started in Linux, it's started in a new subprocess. Besides the greater overhead of the creation of a new process, it also gets a new process ID. And therein is the problem: A different process ID means a different process table. In VMS, you can define a process logical and then start an executable that would use this logical. In Linux, the defined process logical will be gone on exit of the program defining the logical. | + | **LNM_PROCESS is not a table. It's a logical pointing to another table containing the process ID (pid) in its name to separate the many process tables from each other. The behavior of Linux concerning process ID's is different from that of VMS (I will go into more detail on this in part 5 about DCL). DCL (Digital Command Language) is a real shell: it wraps around a process, and every time an executable (“image” in VMS) is started, it runs within this shell, within the same memory, with the same logicals and symbols (environment variables) and with the same process ID. Bash is called a shell, but it is NOT! It is a CLI (Command Line Interpreter). Every time an executable is started in Linux, it's started in a new subprocess. Besides the greater overhead of the creation of a new process, it also gets a new process ID. And therein is the problem: A different process ID means a different process table. In VMS, you can define a process logical and then start an executable that would use this logical. In Linux, the defined process logical will be gone on exit of the program defining the logical. | 
| - | To circumvent this problem I decided to use the process ID of the parent instead. This will be the same every time you start a new executable from the same terminal. Because this causes a different problem (having the same process table) when starting several background (“detached” in VMS) programs from a single terminal or program, I created the program “RunDetached” to do this for you. This again causes all programs to use process ID 1 from the init program, but that is easily detected. In that case its own process ID minus 1 is used. | + | To circumvent this problem I decided to use the process ID of the parent instead. This will be the same every time you start a new executable from the same terminal. Because this causes a different problem (having the same process table) when starting several background (“detached” in VMS) programs from a single terminal or program, I created the program “RunDetached” to do this for you. This again causes all programs to use process ID 1 from the init program, but that is easily detected. In that case its own process ID minus 1 is used.** | 
| - | As mentioned before, logicals are used consistently throughout the entire system in VMS. This means that whenever you want to access a device, VMS will first try to translate the name of the device. To get the same behavior, I created a library function named OPEN to substitute the file access function of VAX-pascal, but this works only for TEXT handles. If another type of file handle is used, than it will be used to determine the file attributes (like record size), and I cannot mimic that. In this case the best solution is to manually replace the OPEN statement by a sequence of: | + | LNM_PROCESS n'est pas une table. C'est un logical qui pointe vers une autre table contenant l'ID du processus (pid) dans son nom pour pouvoir différencier les nombreuses tables de processus. Le comportement de Linux concernant les ID de processus n'est pas le même que celui de VMS (j'en parlerai avec plus de détails dans la partie 5 qui a pour sujet le DCL). Le DCL (Digital Command Language est un vrai shell : il entoure un processus et, chaque fois qu'un exécutable (« image » dans VMS) est lancé, il tourne à l' | 
| + | |||
| + | Pour contourner ce problème, j'ai décidé d' | ||
| + | |||
| + | **As mentioned before, logicals are used consistently throughout the entire system in VMS. This means that whenever you want to access a device, VMS will first try to translate the name of the device. To get the same behavior, I created a library function named OPEN to substitute the file access function of VAX-pascal, but this works only for TEXT handles. If another type of file handle is used, than it will be used to determine the file attributes (like record size), and I cannot mimic that. In this case the best solution is to manually replace the OPEN statement by a sequence of: | ||
| • Call to “translate name” to get the VMS behavior; | • Call to “translate name” to get the VMS behavior; | ||
| • Call to ASSIGN to open the file, while specifying the correct file handle. | • Call to ASSIGN to open the file, while specifying the correct file handle. | ||
| Ligne 201: | Ligne 206: | ||
| The above mentioned functions (“define”, | The above mentioned functions (“define”, | ||
| - | Next month: In the next article I will go more in-depth about other functions such as mailboxes (IPC), what you MUST know about the difference in the way VAX-pascal and Free Pascal handle “PACKED ARRAY OF CHAR” (strings), and how to deal with file version numbers. | + | Next month: In the next article I will go more in-depth about other functions such as mailboxes (IPC), what you MUST know about the difference in the way VAX-pascal and Free Pascal handle “PACKED ARRAY OF CHAR” (strings), and how to deal with file version numbers.** | 
| + | |||
| + | Comme je l'ai déjà dit, les logicals sont utilisés partout dans le système de VMS. Cela veut dire que, chaque fois que vous voudrez accéder à un dispositif, VMS essayera d' | ||
| + | • Appel à « translate name » pour avoir le comportement de VMS ; | ||
| + | • Appel à ASSIGN pour ouvrir le fichier, tout en précisant la bonne poignée de fichier. | ||
| + | J' | ||
| + | |||
| + | Les fonctions mentionnées ci-dessus (« define », etc.) peuvent aussi être réalisées à partir du terminal et j'ai donc créé aussi les trois programmes correspondants. Ils sont - bien entendu - disponibles comme Open Source, tout comme RunDetached. | ||
| + | Le mois prochain : dans le prochain article, je vais approfondir mes explications d' | ||
issue107/tutoriel1.1460623053.txt.gz · Dernière modification : 2016/04/14 10:37 de auntiee
                
                