issue108: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 | ||
issue108:tutoriel1 [2016/05/10 09:26] – d52fr | issue108:tutoriel1 [2016/05/12 11:57] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
**In the early days of computers, a company called Digital Equipment Corporation (DEC) created its 32-bit VAX computer using openVMS as its operating system. Because a VAX/VMS computer is so reliable, there are today - after more than 25 years - still a large number of them in use. But, in the end, even these reliable computers will have to be replaced. As described in part 1, you could migrate from VAX/VMS to Linux, as the way Linux works is largely compatible with VAX/VMS. If you use Pascal as your programming language, you will find that Lazarus/ | **In the early days of computers, a company called Digital Equipment Corporation (DEC) created its 32-bit VAX computer using openVMS as its operating system. Because a VAX/VMS computer is so reliable, there are today - after more than 25 years - still a large number of them in use. But, in the end, even these reliable computers will have to be replaced. As described in part 1, you could migrate from VAX/VMS to Linux, as the way Linux works is largely compatible with VAX/VMS. If you use Pascal as your programming language, you will find that Lazarus/ | ||
- | Au début des ordinateurs, | + | Au début des ordinateurs, |
**Mailboxes | **Mailboxes | ||
Ligne 13: | Ligne 13: | ||
Boîtes mail | Boîtes mail | ||
- | Pour l'IPC (interprocess communication - communication entre processus), VMS offre des boîtes | + | Pour l'IPC (interprocess communication - communication entre processus), VMS offre des boîtes |
- | • Pour créer | + | • Pour créer |
- | Dans Linux, vous devez d' | + | Dans Linux, vous devez d' |
**Now you can create or link to a mailbox using this key as the identifier to get a handle. So you can use two methods: Either create a dummy file for every mailbox you want to use and always use 0 as the small number, or use, e.g., the folder at the base of the current version of your project (see part 3) to get separate mailboxes for every version and assign a constant (smaller than 256) to every mailbox to get the unique key. Whichever method you use, the created mailbox will be permanent. In Linux there are no temporary mailboxes. So be aware of that when starting a new session; you might get old messages left in the mailboxes from a previous run. | **Now you can create or link to a mailbox using this key as the identifier to get a handle. So you can use two methods: Either create a dummy file for every mailbox you want to use and always use 0 as the small number, or use, e.g., the folder at the base of the current version of your project (see part 3) to get separate mailboxes for every version and assign a constant (smaller than 256) to every mailbox to get the unique key. Whichever method you use, the created mailbox will be permanent. In Linux there are no temporary mailboxes. So be aware of that when starting a new session; you might get old messages left in the mailboxes from a previous run. | ||
• Now you are ready to send and receive messages. To send data in VMS, you would fill a buffer with data and make a call to $QIO(W) (see part 2) using the handle of the mailbox you want to put the message into, a pointer to the buffer, and the size of the buffer (plus an eventflag, see part 2). To receive data, you would make the same call to $QIO(W), only the function specifier would be “read” instead of “write”. On return, the buffer will be filled with the received message, and the size parameter will be filled with the size of the received message.** | • Now you are ready to send and receive messages. To send data in VMS, you would fill a buffer with data and make a call to $QIO(W) (see part 2) using the handle of the mailbox you want to put the message into, a pointer to the buffer, and the size of the buffer (plus an eventflag, see part 2). To receive data, you would make the same call to $QIO(W), only the function specifier would be “read” instead of “write”. On return, the buffer will be filled with the received message, and the size parameter will be filled with the size of the received message.** | ||
+ | |||
+ | Maintenant, vous pouvez créer un lien vers une boîte aux lettres en utilisant cette clé comme identifiant pour obtenir un handle (indicateur). Vous pouvez utiliser deux méthodes : soit créer un fichier factice pour chaque boîte aux lettres que vous voulez utiliser et toujours utiliser 0 comme plus petit nombre, ou utiliser, par exemple, le dossier à la base de la version courante de votre projet (voir partie 3), pour disposer d'une boîte aux lettres différente pour chaque version et assigner une constante (inférieure à 256) à chaque boîte pour avoir une clé unique. Quelle que soit la méthode utilisée, la boîte aux lettres créée sera permanente. Dans Linux, il n'y a pas de boîte aux lettres temporaire. Aussi, soyez bien conscient de cela quand vous démarrez une nouvelle session ; vous pourriez trouvez de vieux messages datant d'un fonctionnement précédent. | ||
+ | |||
+ | • Maintenant, vous êtes prêt à envoyer et recevoir des messages. Pour envoyer des données dans VMS, vous rempliriez un tampon (buffer) avec des données et feriez appel à $QIO(W) (voir partie 2) en utilisant le handle de la boîte aux lettres dans laquelle vous voulez placer le message, un pointeur vers le buffer, et la taille du buffer (plus un eventflag, voir partie 2). Pour recevoir des données, vous feriez le même appel à $QIO(W), mais l' | ||
**To send data in Linux, you would fill a buffer just like in VMS, but there must be an extra integer at the beginning of the buffer. This integer value must be filled with a number not being zero! Then you would call sndmsg() with the handle, a pointer to the buffer, and the size of the buffer – not counting the extra integer! To receive a message, you would call rcvmsg() with the same parameters plus a message identifier. This message identifier is used to filter the messages sent to you, so you get only the messages with the matching number in the extra integer value. If the message identifier is zero, there will be no filtering. For example: suppose there are five messages sent to you: message A with that extra integer set to 1, B with 2, C with 1 again, D with 3, and E with 2 again. If you start rcvmsg (...., 2), you will get message B first and then message E. Then rcvmsg (..., 3) will retrieve message D, and, eventually, rcvmsg (...., 0) will get the rest: A and C. If rcvmsg (...., 4) is issued, no messages will be returned. The message size, again not counting the extra integer, is returned as the result of the function. | **To send data in Linux, you would fill a buffer just like in VMS, but there must be an extra integer at the beginning of the buffer. This integer value must be filled with a number not being zero! Then you would call sndmsg() with the handle, a pointer to the buffer, and the size of the buffer – not counting the extra integer! To receive a message, you would call rcvmsg() with the same parameters plus a message identifier. This message identifier is used to filter the messages sent to you, so you get only the messages with the matching number in the extra integer value. If the message identifier is zero, there will be no filtering. For example: suppose there are five messages sent to you: message A with that extra integer set to 1, B with 2, C with 1 again, D with 3, and E with 2 again. If you start rcvmsg (...., 2), you will get message B first and then message E. Then rcvmsg (..., 3) will retrieve message D, and, eventually, rcvmsg (...., 0) will get the rest: A and C. If rcvmsg (...., 4) is issued, no messages will be returned. The message size, again not counting the extra integer, is returned as the result of the function. | ||
Another difference is that, in VMS, you must specify the total size of the mailbox when you create it. In Linux the size is fixed. This might be a problem when using large, or a huge number of, messages.** | Another difference is that, in VMS, you must specify the total size of the mailbox when you create it. In Linux the size is fixed. This might be a problem when using large, or a huge number of, messages.** | ||
+ | |||
+ | Pour envoyer des données dans Linux, vous rempliriez un buffer comme dans VMS, mais il y a un entier supplémentaire au début du buffer. La valeur de cet entier sera un nombre différent de zéro ! Ensuite, vous appelleriez sndmsg() avec le handle, un pointeur vers le buffer, et la taille du buffer - sans compter l' | ||
+ | |||
+ | Autre différence : dans VMS, vous devez spécifier la taille totale de la boîte aux lettres quand vous la créez. Dans Linux, la taille est fixée. Ceci peut être un problème si vous utilisez des messages très grands ou très nombreux. | ||
**The implementation | **The implementation | ||
Ligne 33: | Ligne 41: | ||
• The _QIO(W) will send or receive depending on the function specifier. It uses a new thread and the specified eventflag to create the asynchronous behavior as in VMS (see part 2). | • The _QIO(W) will send or receive depending on the function specifier. It uses a new thread and the specified eventflag to create the asynchronous behavior as in VMS (see part 2). | ||
This way, the only thing you would have to do for the migration is define the above mentioned dedicated logical and add the extra integer in front of the declaration of the buffer. Removing the logical used for a mailbox would cause the creation of a new mailbox upon opening, while the still connected processes would use the old one, exactly like in VMS.** | This way, the only thing you would have to do for the migration is define the above mentioned dedicated logical and add the extra integer in front of the declaration of the buffer. Removing the logical used for a mailbox would cause the creation of a new mailbox upon opening, while the still connected processes would use the old one, exactly like in VMS.** | ||
+ | |||
+ | L' | ||
+ | |||
+ | Au début, j'ai simplement remplacé chaque référence à une boîte aux lettres par l' | ||
+ | • _CREMBX utilise un logical dédié pour pointer vers un fichier contenant l' | ||
+ | • _QIO(W) recevra ou enverra suivant les paramètres de la fonction. Elle utilise un nouveau fil et l' | ||
+ | |||
+ | De cette façon, la seule chose à faire pour la migration est de définir le logical dédié mentionné plus haut et d' | ||
**File version numbers | **File version numbers | ||
Ligne 39: | Ligne 55: | ||
When DEC created ODS-2 (On Disk Structure version 2), it took a different approach. They named all devices (not just disks) with two characters to specify the type, one character starting with A, then B and so on to identify the adapter, plus a serial number. The base folder (directory) on a disk is named [000000] and names and types of files are long like in NTFS and EXT. And they decided that there should be more versions of the same file in the same directory (folder). An example:** | When DEC created ODS-2 (On Disk Structure version 2), it took a different approach. They named all devices (not just disks) with two characters to specify the type, one character starting with A, then B and so on to identify the adapter, plus a serial number. The base folder (directory) on a disk is named [000000] and names and types of files are long like in NTFS and EXT. And they decided that there should be more versions of the same file in the same directory (folder). An example:** | ||
+ | |||
+ | Numéros de versions des fichiers | ||
+ | |||
+ | Cette partie concerne les systèmes de fichiers ; au début, il y avait DOS (et CP/M) qui utilisaient FAT comme système de fichiers. Les noms de fichiers avaient 8 caractères avec un type de fichier de 3 caractères. Plus tard, NTFS (New Technology File System - Système de Fichiers de Nouvelle Technologie) permit des noms et des types longs, et plus d' | ||
+ | |||
+ | Quand DEC a créé ODS-2 (On Disk Structure version 2 - structure sur disque version 2), il a pris une autre approche. Il nomma tous les périphériques (pas seulement les disques) avec deux caractères qui spécifiaient le type, un caractère commençant à A, puis B et ainsi de suite pour identifier l' | ||
**Suppose I create a text file with an editor and save the file. Besides the name and type that I specify, it will also get a version number, starting with “1”. If I would use the editor to change this file and save it again, the existing file will not be overwritten like in Linux and Windows. The editor creates a new file, with the same name and type, but with a higher version number, “2” in this case. The same happens with log files, executables (programs), and so on. The advantage is that you can see the history of a file and even restore a previous version. For example, if a new version of a program does not work as it should, you can just kill the process and start the previous version, it is still there (unless you deleted it). But of course there is also a down-side: For a thousand versions of a file, you need a thousand times the disk-space and the version is limited to 32767. If you go beyond that, the creating program will crash! | **Suppose I create a text file with an editor and save the file. Besides the name and type that I specify, it will also get a version number, starting with “1”. If I would use the editor to change this file and save it again, the existing file will not be overwritten like in Linux and Windows. The editor creates a new file, with the same name and type, but with a higher version number, “2” in this case. The same happens with log files, executables (programs), and so on. The advantage is that you can see the history of a file and even restore a previous version. For example, if a new version of a program does not work as it should, you can just kill the process and start the previous version, it is still there (unless you deleted it). But of course there is also a down-side: For a thousand versions of a file, you need a thousand times the disk-space and the version is limited to 32767. If you go beyond that, the creating program will crash! | ||
If your project is depending on this behavior (the file version, not the crashing), you will have to change your programs. Either by adding a “version number” to the name or type, or by changing your project in such a way it will no longer depend on the file versions. Whichever solution is best depends on the project and there' | If your project is depending on this behavior (the file version, not the crashing), you will have to change your programs. Either by adding a “version number” to the name or type, or by changing your project in such a way it will no longer depend on the file versions. Whichever solution is best depends on the project and there' | ||
+ | |||
+ | Supposez que je crée un fichier texte dans un éditeur et que je le sauvegarde. Outre le nom et le type que je spécifie, il y aura aussi un numéro de version, commençant à « 1 ». Si j' | ||
+ | |||
+ | Si votre projet est sensible à ce comportement (la version de fichier, pas le plantage), vous devrez changer vos programmes. Soit en ajoutant un « numéro de version » aux nom et type, ou en changeant votre projet de telle façon qu'il ne dépende plus des numéros de version. L'une de ces solutions est la meilleure pour votre projet, mais il n'y a pas de solution unique qui réponde à tous les cas. | ||
**Packed array of chars | **Packed array of chars | ||
Ligne 49: | Ligne 75: | ||
Big problems arise when you compare two strings with at least one of them being a packed array of chars. In VAX-Pascal, the remainder of a packed array of chars will be filled with spaces, in Free Pascal the remainder is unknown! As a result, comparing even fails if the strings you use are equal. Suppose you have a packed array of chars with size 10 ([1..10]) named STR. Now fill it with a text of size 4 like “STR := ' | Big problems arise when you compare two strings with at least one of them being a packed array of chars. In VAX-Pascal, the remainder of a packed array of chars will be filled with spaces, in Free Pascal the remainder is unknown! As a result, comparing even fails if the strings you use are equal. Suppose you have a packed array of chars with size 10 ([1..10]) named STR. Now fill it with a text of size 4 like “STR := ' | ||
+ | |||
+ | Les matrices empaquetées de caractères | ||
+ | |||
+ | En Free Pascal, deux mondes se télescopent. D'un côté, il y a les chaînes de type C et, de l' | ||
+ | |||
+ | Les gros problèmes surviennent quand vous comparez deux chaînes et qu'au moins l'une d' | ||
**This is clearly a bug, but I didn't have the time to fill out a bug-report. | **This is clearly a bug, but I didn't have the time to fill out a bug-report. | ||
Ligne 57: | Ligne 89: | ||
Next month: In the next article, I will go more in-depth about DCL (Digital Command Language) – the interface used by Digital when interacting with the terminal, and AST's (Asynchronous System Trap), also named ‘call back routines’, | Next month: In the next article, I will go more in-depth about DCL (Digital Command Language) – the interface used by Digital when interacting with the terminal, and AST's (Asynchronous System Trap), also named ‘call back routines’, | ||
+ | |||
+ | C'est clairement un défaut, mais je n' | ||
+ | |||
+ | Comme contournement, | ||
+ | |||
+ | Des problèmes apparaîtront aussi lors de la déclaration d'une chaîne de type C à partir d'une chaîne empaquetée de caractères. Si le reste de la chaîne empaquetée de caractères est zéro (cas classique), le contenu de la chaîne sera affiché « test » dans le débogueur, pour reprendre l' | ||
+ | |||
+ | La mois prochain : dans le prochain article, j' |
issue108/tutoriel1.1462865199.txt.gz · Dernière modification : 2016/05/10 09:26 de d52fr