Misplaced Pages

Device file

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

A terminate-and-stay-resident program (commonly TSR ) is a computer program running under DOS that uses a system call to return control to DOS as though it has finished, but remains in computer memory so it can be reactivated later. This technique partially overcame DOS's limitation of executing only one program, or task , at a time. TSRs are used only in DOS, not in Windows .

#549450

58-1226: In Unix-like operating systems , a device file , device node , or special file is an interface to a device driver that appears in a file system as if it were an ordinary file . There are also special files in DOS , OS/2 , and Windows . These special files allow an application program to interact with a device by using its device driver via standard input/output system calls . Using standard system calls simplifies many programming tasks, and leads to consistent user-space I/O mechanisms regardless of device features and functions. Device files usually provide simple interfaces to standard devices (such as printers and serial ports), but can also be used to access specific unique resources on those devices, such as disk partitions . Additionally, device files are useful for accessing system resources that have no connection with any actual device, such as data sinks and random number generators . There are two general kinds of device files in Unix-like operating systems, known as character special files and block special files . The difference between them lies in how much data

116-424: A node . The assignment of these numbers occurs uniquely in different operating systems and on different computer platforms . Generally, the major number identifies the device driver and the minor number identifies a particular device (possibly out of many) that the driver controls: in this case, the system may pass the minor number to a driver. However, in the presence of dynamic number allocation , this may not be

174-401: A virtual file system traditionally mounted at /dev , possibly associated with a controlling daemon, which monitors hardware addition and removal at run time, making corresponding changes to the device file system if that's not automatically done by the kernel, and possibly invoking scripts in system or user space to handle special device needs. The FreeBSD , DragonFly BSD and Darwin have

232-469: A POSIX compatibility layer and are not otherwise inherently Unix systems. Many ancient UNIX systems no longer meet this definition. Broadly, any Unix-like system that behaves in a manner roughly consistent with the UNIX specification, including having a " program which manages your login and command line sessions "; more specifically, this can refer to systems such as Linux or Minix that behave similarly to

290-466: A UNIX system but have no genetic or trademark connection to the AT&;T code base. Most free/open-source implementations of the UNIX design, whether genetic UNIX or not, fall into the restricted definition of this third category due to the expense of obtaining Open Group certification, which costs thousands of dollars. Around 2001 Linux was given the opportunity to get a certification including free help from

348-585: A computer to boot into a DOS Kernel by shutting down Windows Me; thus TSRs became useless on Windows Me. The Windows NT series (including Windows 2000 , Windows XP , and later) replaced DOS completely and run in protected mode or long mode (later 64-bit versions only) all the time, disabling the ability to switch to real mode, which is needed for TSRs to function. Instead these operating systems have modern driver and service frameworks with memory protection and preemptive multitasking , allowing multiple programs and device drivers to run simultaneously without

406-418: A computer user might call up several times a day, while working in another program, by using a hotkey . Borland Sidekick was an early and popular example of this type. Others serve as device drivers for hardware that the operating system does not directly support. Normally DOS can run only one program at a time. When a program finishes, it returns control to DOS using the system call INT 21h/4Ch of

464-520: A dedicated file system devfs ; device nodes are managed automatically by this file system, in kernel space . Linux used to have a similar devfs implementation, but it was abandoned later, and then removed since version 2.6.17; Linux now primarily uses a user space implementation known as udev , but there are many variants. In Unix systems which support chroot process isolation, such as Solaris Containers , typically each chroot environment needs its own /dev ; these mount points will be visible on

522-446: A device already in use would discover itself unable to open the device file node. A variety of device driver semantics are implemented in Unix and Linux concerning concurrent access . Device nodes correspond to resources that an operating system's kernel has already allocated. Unix identifies those resources by a major number and a minor number , both stored as part of the structure of

580-583: A historical connection to the AT&;T codebase. Most commercial UNIX systems fall into this category. So do the BSD systems, which are descendants of work done at the University of California, Berkeley in the late 1970s and early 1980s. Some of these systems have no original AT&T code but can still trace their ancestry to AT&T designs. These systems‍—‌largely commercial in nature‍—‌have been determined by

638-873: A misuse of their trademark. Their guidelines require "UNIX" to be presented in uppercase or otherwise distinguished from the surrounding text, strongly encourage using it as a branding adjective for a generic word such as "system", and discourage its use in hyphenated phrases. Other parties frequently treat "Unix" as a genericized trademark . Some add a wildcard character to the name to make an abbreviation like "Un*x" or "*nix", since Unix-like systems often have Unix-like names such as AIX , A/UX , HP-UX , IRIX , Linux , Minix , Ultrix , Xenix , and XNU . These patterns do not literally match many system names, but are still generally recognized to refer to any UNIX system, descendant, or work-alike, even those with completely dissimilar names such as Darwin / macOS , illumos / Solaris or FreeBSD . In 2007, Wayne R. Gray sued to dispute

SECTION 10

#1733085206550

696-507: A program to react to hardware events. Installing a software interrupt vector allows it to be called by the currently running program. Installing a timer interrupt handler allows a TSR to run periodically (using a programmable interval timer ). The typical method of using an interrupt vector involves reading its present value (the address), storing it within the memory space of the TSR, and replacing it with an address in its own code. The stored address

754-579: A script named makedev or MAKEDEV to create all necessary devices in the directory /dev . It only makes sense on systems whose devices are statically assigned major numbers (e.g., by means of hardcoding it in their kernel module). Some other Unix systems such as FreeBSD use kernel-based device node management via devfs only and do not support manual node creation. mknod(2) system call and mknod(8) command exist to keep compatibility with POSIX, but manually created device nodes outside devfs will not function at all. The following prefixes are used for

812-497: A single menu entry. In the mid- to later 1990s, while many games were still written for DOS, the 640 KB limit was eventually overcome by putting parts of the game's data above the first 1 MB of memory and using the code below 640 KB to access the extended memory using expanded memory (EMS) by making use of overlay technique. An alternative later approach was to switch the CPU into Protected Mode by using DOS extenders and run

870-475: A variety of proprietary systems were developed based on it, including AIX , HP-UX , IRIX , SunOS , Tru64 , Ultrix , and Xenix . These largely displaced the proprietary clones. Growing incompatibility among these systems led to the creation of interoperability standards, including POSIX and the Single UNIX Specification . Various free, low-cost, and unrestricted substitutes for UNIX emerged in

928-465: A widespread traction among programmers in its days. It existed alongside several other competing specifications of varying sophistication. While very useful, or even essential to overcome DOS 's limitations, TSRs have a reputation as troublemakers. Many hijack the operating system in varying documented or undocumented ways, often causing systems to crash on their activation or deactivation when used with particular applications or other TSRs. By chaining

986-403: Is called loading high . Later, memory managers started including programs such as Quarterdeck's Optimize or Microsoft's MEMMAKER which try to maximize the available space in the first 640 KB by determining how best to allocate TSRs between low and high memory. With the development of games using DOS extenders (an early example was Doom ) which bypassed the 640 KB barrier, many of

1044-640: Is called from the TSR, in effect forming a singly linked list of interrupt handlers , also called interrupt service routines , or ISRs. This procedure of installing ISRs is called chaining or hooking an interrupt or an interrupt vector. TSRs can be loaded at any time; either during the DOS startup sequence (for example, from AUTOEXEC.BAT ), or at the user's request (for example, Borland 's Sidekick and Turbo Debugger, Quicken's QuickPay, or FunStuff Software's Personal Calendar). Parts of DOS itself use this technique, especially in DOS versions 5.0 and later. For example,

1102-416: Is followed by a number uniquely identifying the particular device. For hard drives, a letter is used to identify devices and is followed by a number to identify partitions . Thus a file system may "know" an area on a disk as /dev/sda3 , for example, or "see" a networked terminal session as associated with /dev/pts/14 . On disks using the typical PC master boot record , the device numbers of primary and

1160-535: Is made up of many small, interchangeable components that can be added or removed as needed. This makes it easy to customize the operating system to suit the needs of different users or environments. The Open Group owns the UNIX trademark and administers the Single UNIX Specification, with the "UNIX" name being used as a certification mark . They do not approve of the construction "Unix-like", and consider it

1218-405: Is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification . A Unix-like application is one that behaves like the corresponding Unix command or shell . Although there are general philosophies for Unix design, there is no technical standard defining the term, and opinions can differ about

SECTION 20

#1733085206550

1276-514: Is read and written by the operating system and hardware. These together can be called device special files in contrast to named pipes , which are not connected to a device but are not ordinary files either. MS-DOS borrowed the concept of special files from Unix but renamed them devices . Because early versions of MS-DOS did not support a directory hierarchy, devices were distinguished from regular files by making their names reserved words that cannot be used as folder or file names; for example:

1334-439: Is that because block devices are buffered, the programmer does not know how long it will take before written data is passed from the kernel's buffers to the actual device, or indeed in what order two separate writes will arrive at the physical device. Additionally, if the same hardware exposes both character and block devices, there is a risk of data corruption due to clients using the character device being unaware of changes made in

1392-418: Is their ability to support multiple users and processes simultaneously. This allows users to run multiple programs at the same time and to share resources such as memory and disk space. This is in contrast to many older operating systems, which were designed to only support a single user or process at a time. Another important feature of Unix-like systems is their modularity . This means that the operating system

1450-617: The AVAILDEV CONFIG.SYS parameter that, if set to FALSE , makes these special names only active if prefixed with \DEV\ , thus allowing ordinary files to be created with these names. GEMDOS , the DOS-like part of Atari TOS , supported similar device names to DOS, but unlike DOS it required a trailing ":" character (on DOS, this is optional) to identify them as devices as opposed to normal filenames (thus "CON:" would work on both DOS and TOS, but "CON" would name an ordinary file on TOS but

1508-455: The DOS API . The memory and system resources used are then marked as unused. This makes it impossible to restart parts of the program without having to reload it all. However, if a program ends with the system call INT 27h or INT 21h/31h , the operating system does not reuse a certain specified part of its memory. The original call, INT 27h , is called "terminate but stay resident", hence

1566-535: The DOSKEY command-line editor and various other utilities are installed by running them at the command line (manually, or from AUTOEXEC.BAT or through INSTALL from within CONFIG.SYS ) rather than loading them as device drivers through DEVICE statements in CONFIG.SYS. Some TSRs have no way to unload themselves, so they will remain in memory until a reboot. However unloading is possible externally, using utilities like

1624-607: The MARK.EXE / RELEASE.EXE combo by TurboPower Software or soft reboot TSRs which will catch a specific key combination and release all TSRs loaded after them. As the chain of ISRs is singly linked, and a TSR may store the link to its predecessor anywhere it chooses, there is no general way for a TSR to remove itself from the chain. So usually a stub must be left in memory when unloading a TSR, causing memory fragmentation. This problem gave rise to TSR cooperation frameworks such as TesSeRact and AMIS. To manage problems with many TSRs sharing

1682-520: The Open Group to meet the Single UNIX Specification and are allowed to carry the UNIX name. Most such systems are commercial derivatives of the System V code base in one form or another, although Apple macOS 10.5 and later is a BSD variant that has been certified, and EulerOS and Inspur K-UX are Linux distributions that have been certified. A few other systems (such as IBM z/OS) earned the trademark through

1740-687: The PC-E500 , PC-E500S etc. consists of a BASIC interpreter, a DOS 2-like File Control System (FCS) implementing a rudimentary 12-bit FAT -like filesystem, and a BIOS-like Input/Output Control System (IOCS) implementing a number of standard character and block device drivers as well as special file devices including STDO:/SCRN: (display), STDI:/KYBD: (keyboard), COM: (serial I/O), STDL:/PRN: (printer), CAS: (cassette tape), E:/F:/G: (memory file), S1:/S2:/S3: (memory card), X:/Y: (floppy), SYSTM: (system), and NIL: (function). Unix-like A Unix-like (sometimes referred to as UN*X or *nix ) operating system

1798-439: The 1 MB boundary, and possible to run code in that area, when the x86 processor is switched from real mode to protected mode . However, since DOS and most DOS programs run in real mode (VCPI or DPMI makes a protected-mode program look like a real-mode program to DOS and the rest of the system by switching back and forth between the two modes), DOS TSRs and device drivers also run in real mode, and so any time one gets control,

Device file - Misplaced Pages Continue

1856-508: The 1980s and 1990s, including 4.4BSD , Linux , and Minix . Some of these have in turn been the basis for commercial "Unix-like" systems, such as BSD/OS and macOS . Several versions of (Mac) OS X/macOS running on Intel-based Mac computers have been certified under the Single UNIX Specification . The BSD variants are descendants of UNIX developed by the University of California at Berkeley, with UNIX source code from Bell Labs . However,

1914-539: The BSD code base has evolved since then, replacing all the AT&T code. Since the BSD variants are not certified as compliant with the Single UNIX Specification, they are referred to as "UNIX-like" rather than "UNIX". Dennis Ritchie , one of the original creators of Unix, expressed his opinion that Unix-like systems such as Linux are de facto Unix systems. Eric S. Raymond and Rob Landley have suggested that there are three kinds of Unix-like systems: Those systems with

1972-701: The DOS extender has to switch back to real mode until it relinquishes control, incurring a time penalty (unless they utilize techniques such as DPMS or CLOAKING ). With the arrival of expanded memory boards and especially of Intel 80386 processors in the second half of the 1980s, it became possible to use memory above 640 KB to load TSRs. This required complex software solutions, named expanded memory managers . Some memory managers are QRAM and QEMM by Quarterdeck , 386 by Qualitas , CEMM by Compaq , and later EMM386 by Microsoft . The memory areas usable for loading TSRs above 640 KB are called " upper memory blocks " (UMBs) and loading programs into them

2030-517: The Folder Options control panel." Attempting to rename any file or folder using a reserved name silently reverts the object to its previous name (or "New Folder", "New Text Document", etc.), with no notification or error message. In Windows Vista and later, attempting to use a reserved name for a file or folder brings up an error message saying, "The specified device name is invalid." In some Unix-like systems, most device files are managed as part of

2088-506: The IDE devices are named /dev/wd0 , /dev/wd1 , etc. devfs is a specific implementation of a device file system on Unix-like operating systems, used for presenting device files. The underlying mechanism of implementation may vary, depending on the OS. Maintaining these special files on a physically-implemented file system such as a hard drive is inconvenient, and as it needs kernel assistance anyway,

2146-498: The PC platform pushed up against this limit and left less and less space for TSRs—even essential ones like CD-ROM drivers—and arranging things so that there was enough free RAM to run the games, while keeping the necessary TSRs present, became very complicated. Many gamers had several boot disks with different configurations for different games. In later versions of MS-DOS, "boot menu" scripts allowed various configurations to be selectable via

2204-827: The POSIX chair Andrew Josey for the symbolic price of one dollar. There have been some activities to make Linux POSIX-compliant, with Josey having prepared a list of differences between the POSIX standard and the Linux Standard Base specification, but in August 2005, this project was shut down because of missing interest at the LSB work group. Some non-Unix-like operating systems provide a Unix-like compatibility layer , with varying degrees of Unix-like functionality. Other means of Windows-Unix interoperability include: Terminate-and-stay-resident program Some TSRs are utility software that

2262-662: The buffers of the block device. Most systems create both block and character devices to represent hardware like hard disks. FreeBSD and Linux notably do not; the former has removed support for block devices, while the latter creates only block devices. To get the effect of a character device from a block device on Linux, one must open the device with the Linux-specific O_DIRECT flag. Device nodes on Unix-like systems do not necessarily have to correspond to physical devices . Nodes that lack this correspondence are called pseudo-devices . They provide various functions handled by

2320-482: The case (e.g. on FreeBSD 5 and up). As with other special file types, the computer system accesses device nodes using standard system calls and treats them like regular computer files. Two standard types of device files exist; unfortunately their names are rather counter-intuitive for historical reasons, and explanations of the difference between the two are often incorrect as a result. Character special files or character devices provide unbuffered, direct access to

2378-992: The concept of special files from Unix but renamed them devices . Because early versions of MS-DOS did not support a directory hierarchy, devices were distinguished from regular files by making their names reserved words . This means that certain file names were reserved for devices, and should not be used to name new files or directories. The reserved names themselves were chosen to be compatible with "special files" handling of PIP command in CP/M . There were two kinds of devices in DOS: Block Devices (used for disk drives) and Character Devices (generally all other devices, including COM and PRN devices). DOS uses device files for accessing printers and ports. Most versions of Windows also contain this support, which can cause confusion when trying to make files and folders of certain names, as they cannot have these names. Versions 2.x of MS-DOS provide

Device file - Misplaced Pages Continue

2436-464: The console device on DOS). In MiNT and MagiC , a special UNIX-like unified filesystem view accessed via the "U:" drive letter also placed device files in "U:\DEV". Using shell redirection and pipes, data can be sent to or received from a device. For example, typing the following will send the file c:\data.txt to the printer: PIPE, MAILSLOT, and MUP are other standard Windows devices. The 8-bit operating system of Sharp pocket computers like

2494-528: The degree to which a particular operating system or application is Unix-like. Some well-known examples of Unix-like operating systems include Linux and BSD . These systems are often used on servers as well as on personal computers and other devices. Many popular applications, such as the Apache web server and the Bash shell, are also designed to be used on Unix-like systems. One of the key features of Unix-like systems

2552-451: The fact that a character device for a piece of block-based hardware will typically require programs to read and write aligned blocks. Block special files or block devices provide buffered access to hardware devices, and provide some abstraction from their specifics. Unlike character devices, block devices will always allow the programmer to read or write a block of any size (including single characters/bytes) and any alignment. The downside

2610-442: The first 640  KB of RAM (the conventional memory ). TSRs are no exception, and take chunks from that 640 KB that are thus unavailable to other applications. This meant that writing a TSR was a challenge of achieving the smallest possible size for it, and checking it for compatibility with a lot of software products from different vendors—often a very frustrating task. In the late 1980s and early 1990s, many video games on

2668-424: The hardware device. They do not necessarily allow programs to read or write single characters at a time; that is up to the device in question. The character device for a hard disk, for example, will normally require that all reads and writes be aligned to block boundaries and most certainly will not allow reading a single byte. Character devices are sometimes known as raw devices to avoid the confusion surrounding

2726-518: The host OS at various nodes in the global file system tree. By restricting the device nodes populated into chroot instances of /dev , hardware isolation can be enforced by the chroot environment (a program can not meddle with hardware that it can neither see nor name—an even stronger form of access control than Unix file system permissions ). MS-DOS managed hardware device contention (see terminate-and-stay-resident program ) by making each device file exclusive open. An application attempting to access

2784-495: The idea arose of a special-purpose logical file system that is not physically stored. Defining when devices are ready to appear is not trivial. The devfs approach is for the device driver to request creation and deletion of devfs entries related to the devices it enables and disables. A device file is a reserved keyword used in PC DOS , TOS , OS/2 , and Windows systems to allow access to certain ports and devices. MS-DOS borrowed

2842-523: The interrupt vectors TSRs can take complete control of the computer. A TSR can have one of two behaviors: The terminate-and-stay-resident method is used by most DOS viruses and other malware, which can either take control of the PC or stay in the background. This malware can react to disk I/O or execution events by infecting executable (.EXE or .COM) files when it is run and data files when they are opened. Additionally, in DOS all programs, even those with large amounts of physical RAM , must be loaded into

2900-425: The issues relating to TSRs disappeared, and with the widespread adoption of Microsoft Windows and especially Windows 95 (followed by Windows 98 ) – which rendered most TSRs unnecessary and some TSRs incompatible – the TSR faded into obsolescence, though Win16 applications can do TSR-like tricks such as patching the interrupt descriptor table (IDT) because Windows allowed it. Windows Me does not allow

2958-437: The name "TSR". Using this call, a program can make up to 64 KB of its memory resident. MS-DOS version 2.0 introduced an improved call, INT 21h/31h ('Keep Process'), which removed this limitation and let the program return an exit code . Before making this call, the program can install one or several interrupt handlers pointing into itself, so that it can be called again. Installing a hardware interrupt vector allows such

SECTION 50

#1733085206550

3016-506: The names of some devices in the /dev hierarchy, to identify the type of device: Some additional prefixes have come into common use in some operating systems: The canonical list of the prefixes used in Linux can be found in the Linux Device List , the official registry of allocated device numbers and /dev directory nodes for the Linux operating system. For most devices, this prefix

3074-470: The operating system. Some of the most commonly used (character-based) pseudo-devices include: Additionally, BSD-specific pseudo-devices with an ioctl interface may also include: Nodes are created by the mknod system call . The command-line program for creating nodes is also called mknod . Nodes can be moved or deleted by the usual filesystem system calls ( rename , unlink ) and commands ( mv , rm ). Some Unix versions include

3132-429: The optional extended partition are numbered 1 through 4, while the indexes of any logical partitions are 5 and onwards, regardless of the layout of the former partitions (their parent extended partition does not need to be the fourth partition on the disk, nor do all four primary partitions have to exist). Device names are usually not portable between different Unix-like system variants, for example, on some BSD systems,

3190-419: The program in protected mode. The latter allowed to have code and data in the extended memory area. Because programming with many overlays is a challenge in and of itself, once the program was too big to fit entirely into about 512 KB, use of extended memory was almost always done using a third-party DOS extender implementing VCPI or DPMI , because it becomes much easier and faster to access memory above

3248-458: The same interrupt, a method called Alternate Multiplex Interrupt Specification (AMIS) was proposed by Ralf D. Brown as an improvement over previously used services offered via INT 2Fh. AMIS provides ways to share software interrupts in a controlled manner. It is modeled after IBM's Interrupt Sharing Protocol, originally invented for sharing hardware interrupts of an x86 processor. AMIS services are available via Int 2Dh. The proposal never gained

3306-508: The status of UNIX as a trademark, but lost his case, and lost again on appeal, with the court upholding the trademark and its ownership. "Unix-like" systems started to appear in the late 1970s and early 1980s. Many proprietary versions, such as Idris (1978), UNOS (1982), Coherent (1983), and UniFlex (1985), aimed to provide businesses with the functionality available to academic users of UNIX. When AT&T allowed relatively inexpensive commercial binary sublicensing of UNIX in 1979,

3364-482: The word CON is a reserved word. These were chosen for a degree of compatibility with CP/M and are still present in modern Windows for backwards compatibility. Names are not case-sensitive, so "con", "Con", and "CON" are all invalid names. In Windows XP , entering "Con" into the Run command returns the error message, "This file does not have a program associated with it for performing this action. Create an association in

#549450