Operating System File 5 & 6
Operating System File 5 & 6
Setup
#include<stdio.h>
#include<pthread.h>
#include<unistd.h>
void *function1(); void
*function2();
pthread_mutex_t first_mutex; //mutex lock
pthread_mutex_t second_mutex;
int main() {
pthread_mutex_init(&first_mutex,NULL); //initialize the lock
pthread_mutex_init(&second_mutex,NULL);
pthread_t one, two;
pthread_create(&one, NULL, function1, NULL); // create thread
pthread_create(&two, NULL, function2, NULL); pthread_join(one,
NULL);
pthread_join(two, NULL);
printf("Thread joined\n");
}
void *function1( ) {
sleep(1); pthread_mutex_lock(&second_mutex);
pthread_mutex_unlock(&first_mutex);
Digital file systems and files are named for and modeled after paper- based
filing systems using the same logic-based method of storing and retrieving
documents.
File systems can differ between operating systems (OS), such as Microsoft
Windows, macOS and Linux-based systems. Some file systems are
designed for specific applications. Major types of file systems include
distributed file systems, disk-based file systems and special purpose file
systems.
File systems specify conventions for naming files, including the maximum
number of characters in a name, which characters can be used and, in some
systems, how long the file name suffix can be. In many file systems, file names
are not case sensitive.
Along with the file itself, file systems contain information such as the size of
the file, as well as its attributes, location and hierarchy in the directory in the
metadata. Metadata can also identify free blocks of available storage on the
drive and how much space is available.
Example of a file tree diagram
A file system also includes a format to specify the path to a file through the
structure of directories. A file is placed in a directory -- or a folder in Windows
OS -- or subdirectory at the desired place in the tree structure. PC and mobile
OSes have file systems in which files are placed somewhere in a hierarchical
tree structure.
Before files and directories are created on the storage medium, partitions should
be put into place. A partition is a region of the hard disk or other storage that the
OS manages separately. One file system is contained in the primary partition,
and some OSes allow for multiple partitions on one disk. In this situation, if one
file system gets corrupted, the data in a different partition will be safe.
• Date modified
• Last date of access
• Last backup
• User ID of the file creator
• Access permissions
• File size
Metadata is stored separately from the contents of the file, with many file
systems storing the file names in separate directory entries. Some metadata may
be kept in the directory, whereas other metadata may be kept in a structure
called an inode.
File permissions such as access or capability control lists can also be used to
moderate file system access. These types of mechanisms are useful to prevent
access by regular users, but not as effective against outside intruders.
Encrypting files can also prevent user access, but it is focused more on
protecting systems from outside attacks. An encryption key can be applied to
unencrypted text to encrypt it, or the key can be used to decrypt encrypted text.
Only users with the key can access the file. With encryption, the file system
does not need to know the encryption key to manage the data effectively.
File allocation table (FAT) is supported by the Microsoft Windows OS. FAT
is considered simple and reliable, and it is modeled after legacy file systems.
FAT was designed in 1977 for floppy disks, but was later adapted for hard
disks. While efficient and compatible with most current OSes, FAT cannot
match the performance and scalability of more modern file systems.
Global file system (GFS) is a file system for the Linux OS, and it is a shared
disk file system. GFS offers direct access to shared block storage and can be
used as a local file system.
GFS2 is an updated version with features not included in the original GFS, such
as an updated metadata system. Under the terms of the GNU General Public
License, both the GFS and GFS2 file systems are available as free software.
Hierarchical file system (HFS) was developed for use with Mac operating
systems. HFS can also be referred to as Mac OS Standard, and it was succeeded
by Mac OS Extended. Originally introduced in 1985 for floppy and hard disks,
HFS replaced the original Macintosh file system. It can also be used on CD-
ROMs.
The NT file system -- also known as the New Technology File System
(NTFS) -- is the default file system for Windows products from Windows NT
3.1 OS onward. Improvements from the previous FAT file system include better
metadata support, performance and use of disk space. NTFS is also supported in
the Linux OS through a free, open-source NTFS driver. Mac OSes have read-
only support for NTFS.
The centralized structure of a DBMS allows for easier file sharing than a file
system and prevents anomalies that can occur when separate changes are made
to files in a file system.
There are methods to protect files in a file system, but for heavy-duty security, a
DBMS is the way to go. Security in a file system is determined by the OS, and
it can be difficult to maintain over time as files are accessed and authorization is
granted to users.
The term file system can also refer to the part of an OS or an add-on program
that supports a file system. Examples of such add-on file systems include the
Network File System (NFS) and the Andrew File System (AFS).
In addition, the term has evolved to refer to the hardware used for nonvolatile
storage, the software application that controls the hardware and architecture of
both hardware and software.