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/13 18:51] – 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... | ||
Ligne 64: | Ligne 63: | ||
• In Linux, the system is located on '/'; | • In Linux, the system is located on '/'; | ||
- | • 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:”.** |
- | • 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: | + | 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' | ||
+ | L' | ||
+ | Exemples d' | ||
+ | |||
+ | Pour clarifier cet outil complexe, je donnerai quelques exemples de la manière d' | ||
+ | |||
+ | • 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'a pas besoin de connaître le dispositif qui l'a démarré ; il ne fait que lire sur et écrire vers « TT: » (remarquez le deux-points qui indique que TT est un dispositif, pas un dossier). À ne pas confondre avec stdin et stdout. Ceux-ci sont des poignées de dossier qui ouvrent le fichier « TT: ». | ||
+ | |||
+ | **• 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: | ||
define/ | define/ | ||
Ligne 83: | Ligne 93: | ||
define/job OUTPUT_FOLDER MYDISK0: | define/job OUTPUT_FOLDER MYDISK0: | ||
- | 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: |
- | • 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, | + | • 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), puis mis le résultat dans un autre dossier. Vous pourriez définir 2 logicals de type group qui pointent vers ses dossiers : |
+ | |||
+ | define/ | ||
+ | |||
+ | define/ | ||
+ | |||
+ | Votre processus chercherait alors des entrées en utilisant la spécification de fichier INPUT_FOLDER: | ||
+ | |||
+ | 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 : | ||
+ | |||
+ | define/job INPUT_FOLDER MYDISK0: | ||
+ | |||
+ | define/job OUTPUT_FOLDER 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, | ||
new_scale := $TRNLNM (“NEW_SCALE”); | new_scale := $TRNLNM (“NEW_SCALE”); | ||
Ligne 99: | Ligne 125: | ||
define/ | define/ | ||
- | 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: |
- | The logical KW21 used as pointer to the current version is created with: | + | |
+ | • 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 le processus qui lit la balance, puis le redémarrer avec l' | ||
+ | |||
+ | new_scale := $TRNLNM (“NEW_SCALE”); | ||
+ | |||
+ | if new_scale = ' | ||
+ | |||
+ | Vous pourriez vous servir de la commande terminal suivante pour utiliser la nouvelle balance : | ||
+ | |||
+ | define/ | ||
+ | |||
+ | et, pour vous servir de la vieille balance : | ||
+ | |||
+ | define/ | ||
+ | |||
+ | 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: | ||
define/ | define/ | ||
Ligne 110: | Ligne 153: | ||
The only drawback of this method is that you have to use KW21: | The only drawback of this method is that you have to use KW21: | ||
- | There is a lot more to tell about logicals. If you want to read more about logicals and have some time on your hands, try google with “VMS logicals”. | + | There is a lot more to tell about logicals. If you want to read more about logicals and have some time on your hands, try google with “VMS logicals”.** |
- | How to handle logicals? | + | Le logical KW21 utilisé comme pointeur vers la version actuelle est créé par : |
+ | |||
+ | define/ | ||
+ | |||
+ | L' | ||
+ | |||
+ | 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: | ||
+ | |||
+ | Il y a bien plus de choses à dire sur les logicals. Si vous voulez en lire davantage et avez un peu de temps libre, faites une recherche sur Google de « VMS logicals ». | ||
+ | |||
+ | **How to handle logicals? | ||
I tried replacing the logicals using hard links, but that works only for logicals with only 1 translation. And - as with eventflags - you can ask the system what the value of a logical is – a feature that cannot be implemented with hard links. This way, you could also define a kind of “system parameters” to be used by running processes. This makes it possible to implement software changes that can be switched on and off by changing the value of a logical instead of stopping a process and restarting it using a different executable. Or changing to or from daylight saving time without setting the clock. The list of other possible uses in VMS is long. | I tried replacing the logicals using hard links, but that works only for logicals with only 1 translation. And - as with eventflags - you can ask the system what the value of a logical is – a feature that cannot be implemented with hard links. This way, you could also define a kind of “system parameters” to be used by running processes. This makes it possible to implement software changes that can be switched on and off by changing the value of a logical instead of stopping a process and restarting it using a different executable. Or changing to or from daylight saving time without setting the clock. The list of other possible uses in VMS is long. | ||
- | 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...** |
- | My solution | + | Comment gérer les logicals ? |
+ | |||
+ | J'ai essayé de remplacer des logicals par des liens matériels, mais cela ne fonctionne qu' | ||
+ | |||
+ | Pour la liste de recherche, vous pouvez utiliser des variables d' | ||
+ | |||
+ | **My solution | ||
To use logicals on Linux, I created a few procedures in my library to replace the VMS functions to define, delete (“deassign”) and translate logicals. In VMS, the logicals are part of the kernel and located in the kernel' | To use logicals on Linux, I created a few procedures in my library to replace the VMS functions to define, delete (“deassign”) and translate logicals. In VMS, the logicals are part of the kernel and located in the kernel' | ||
- | Upon program start, the shared tables (system, group and job) are opened (or created if necessary), and mapped into shared memory, so they can be accessed directly. This happens only as soon as any of the logical-library routines is called for the first time. Any changes due to (re)defining or removing of logicals are written back to the corresponding file and are immediately visible by other processes as it's mapped into shared memory. The process local table (LNM_PROCESS) is created and also mapped into memory, but not shared. And here lies a little problem: | + | Upon program start, the shared tables (system, group and job) are opened (or created if necessary), and mapped into shared memory, so they can be accessed directly. This happens only as soon as any of the logical-library routines is called for the first time. Any changes due to (re)defining or removing of logicals are written back to the corresponding file and are immediately visible by other processes as it's mapped into shared memory. The process local table (LNM_PROCESS) is created and also mapped into memory, but not shared. And here lies a little problem:** |
- | 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. | + | Ma solution |
- | 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 | + | 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 ») et traduire des logicals. Dans VMS, les logicals font partie du noyau et se trouvent dans la « mémoire paginée » de celui-ci. La taille de cette partie de la mémoire du noyau peut croître ; cette partie de la mémoire peut aussi être temporairement placée dans le swap (VMS: paged out). Puisque ma solution est créée dans l' |
- | 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: | + | 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 partagée, ce qui les rend accessibles directement. Cela a lieu uniquement quand n' |
+ | |||
+ | **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.** | ||
+ | |||
+ | 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 135: | 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.1460566280.txt.gz · Dernière modification : 2016/04/13 18:51 de auntiee