Os-Unit 5-BSC

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Directory Structure

A directory is a container that is used to contain files and sub-directories


(folders). It organizes files and folders in a hierarchical manner.

There are several logical structures of a directory, these are given below.
1.Single-level directory:
The single-level directory is the simplest directory structure. In it, all files are
contained in the same directory which makes it easy to support and
understand.
A single level directory has a significant limitation, however, when the number
of files increases or when the system has more than one user. Since all the
files are in the same directory, they must have a unique name. If two users call
their dataset test, then the unique name rule violated.

Advantages:
 Since it is a single directory, so its implementation is very easy.
 If the files are smaller in size, searching will become faster.
 The operations like file creation, searching, deletion, updating is very easy in
such a directory structure.
2.Two-level directory:
As we have seen, a single level directory often leads to confusion of files names
among different users. the solution to this problem is to create a separate
directory for each user.
In the two-level directory structure, each user has their own user files
directory (UFD). The UFDs have similar structures, but each lists only the files
of a single user.
system’s master file directory (MFD) is searches whenever a new user id=s
logged in. The MFD is indexed by username or account number, and each
entry points to the UFD for that user.

Advantages:
 We can give full path like /User-name/directory-name/.
 Different users can have the same directory as well as the file name.
 Searching of files becomes easier due to pathname and user-grouping.
3.Tree-structured directory –
Once we have seen a two-level directory as a tree of height 2, the natural
generalization is to extend the directory structure to a tree of arbitrary height.
This generalization allows the user to create their own subdirectories and to
organize their files accordingly.

A tree structure is the most common directory structure. The tree has a root
directory, and every file in the system has a unique path.
Advantages:
 Very general, since full pathname can be given.
 Very scalable, the probability of name collision is less.
 Searching becomes very easy, we can use both absolute paths as well as
relative.
******.
File Operations
A file is a collection of related information that is stored on secondary storage. Or
file is a collection of logically related entities. The name of the file is divided into
two parts: name and extension, separated by a period.
A file is an abstract data type. To define a file properly, we need to consider the
operations that can be performed on files.
Six basic file operations. The OS can provide system calls to create, write, read,
reposition, delete, and truncate files.

1. Creating a file: Two steps are necessary to create a file.


 Space in the file system must be found for the file.
 An entry for the new file must be made in the directory.
2. Writing a file: To write a file, we make a system call specifying both the name
of the file and the information to be written to the file. The system must keep
a write pointer to the location in the file where the next write is to take place. The
write pointer must be updated whenever a write occurs.
3. Reading a file: To read from a file, we use a system call that specifies the name
of the file and where (in memory) the next block of the file should be put. The
system needs to keep a read pointer to the location in the file where the next read is
to take place.
 Because a process is usually either reading from or writing to a file, the
current operation location can be kept as a per-process current-file-position
pointer.
 Both the read and write operations use this same pointer, saving space and
reducing system complexity.
4. Repositioning within a file: The directory is searched for the appropriate entry,
and the current-file-position pointer is repositioned to a given value. Repositioning
within a file need not involve any actual I/O. This file operation is also known as a
file seek.
5. Deleting a file: To delete a file, we search the directory for the named file.
Having found the associated directory entry, we release all file space, so that it can
be reused by other files, and erase the directory entry.
6. Truncating a file: The user may want to erase the contents of a file but keep its
attributes. Rather than forcing the user to delete the file and then recreate it, this
function allows all attributes to remain unchanged (except for file length) but lets
the file be reset to length zero and its file space released.
******
File Allocation Methods
There are different types of file allocation methods, but we mainly use three types
of file allocation methods:
1. Contiguous Allocation
2. Linked list Allocation
3. Indexed Allocation
These methods provide quick access to the file blocks and also the utilization of
disk space in an efficient manner.
1.Contiguous Allocation: - Contiguous allocation is one of the most used methods for
allocation. Contiguous allocation means we allocate the block in such a manner,
so that in the hard disk, all the blocks get the contiguous physical block.
We can see in the below figure that in the directory, we have three files. In the
table, we have mentioned the starting block and the length of all the files. We can
see in the table that for each file, we allocate a contiguous block.

Example of contiguous allocation:


We can see in the given diagram, that there is a file. The name of the file is ‘mail.’
The file starts from the 19th block and the length of the file is 6. So, the file
occupies 6 blocks in a contiguous manner. Thus, it will hold blocks 19, 20, 21,
22, 23, 24.

Advantages of Contiguous Allocation:


 The contiguous allocation method gives excellent read performance.
 Contiguous allocation is easy to implement.
 The contiguous allocation method supports both types of file access methods
that are sequential access and direct access.
 The Contiguous allocation method is fast because, in this method number of
seeks is less due to the contiguous allocation of file blocks.
Disadvantages of Contiguous Allocation:
 In the contiguous allocation method, sometimes disk can be fragmented.
 In this method, it is difficult to increase the size of the file due to the
availability of the contiguous memory block.
2.Linked List Allocation:
The linked list allocation method overcomes the drawbacks of the contiguous
allocation method. In this file allocation method, each file is treated as a linked list
of disks blocks. In the linked list allocation method, it is not required that disk
blocks assigned to a specific file are in the contiguous order on the disk. The
directory entry comprises of a pointer for starting file block and also for the ending
file block. Each disk block that is allocated or assigned to a file consists of a
pointer, and that pointer point the next block of the disk, which is allocated to the
same file.
Example of linked list allocation:
We can see in the below figure that we have a file named ‘jeep.’ The value of the
start is 9. So, we have to start the allocation from the 9th block, and blocks are
allocated in a random manner. The value of the end is 25. It means the allocation
is finished on the 25th block. We can see in the below figure that the block (25)
comprised of -1, which means a null pointer, and it will not point to another
block.

Advantages of Linked list allocation


 In liked list allocation, there is no external fragmentation. Due to this, we
can utilize the memory better.
 In linked list allocation, a directory entry only comprises of the starting block
address.
 The linked allocation method is flexible because we can quickly increase the
size of the file because, in this to allocate a file, we do not require a chunk of
memory in a contiguous form.
Disadvantages of Linked list Allocation
 Linked list allocation does not support direct access or random access.
 In linked list allocation, we need to traverse each block.
 If the pointer in the linked list break in linked list allocation, then the file
gets corrupted.
 In the disk block for the pointer, it needs some extra space.
3.Indexed Allocation:
The Indexed allocation method is another method that is used for file allocation.
In the index allocation method, we have an additional block, and that block is
known as the index block. For each file, there is an individual index block. In the
index block, the ith entry holds the disk address of the ith file block. We can see in
the below figure that the directory entry comprises of the address of the index
block.

Advantages of Index Allocation


 The index allocation method solves the problem of external fragmentation.
 Index allocation provides direct access.
Disadvantages of Index Allocation
 In index allocation, pointer overhead is more.
 We can lose the entire file if an index block is not correct.
 It is totally wastage to create an index for a small file.
*******
Device Management
Device management in operating system known as the management of the I/O
devices such as a keyboard, magnetic tape, disk, printer, microphone, USB ports,
scanner, etc. as well as the supporting units like control channels.
An operating system or the OS manages communication with the devices through
their respective drivers. The operating system component provides a uniform
interface to access devices of varied physical attributes.
For device management in operating system:
 Keep tracks of all devices and the program which is responsible to perform
this is called I/O controller.
 Monitoring the status of each device such as storage drivers, printers and
other peripheral devices.
 Enforcing preset policies and taking a decision which process gets the device
when and for how long.
 Allocates and Deallocates the device in an efficient way. De-allocating them
at two levels: at the process level when I/O command has been executed and
the device is temporarily released, and at the job level, when the job is
finished and the device is permanently released.
 Optimizes the performance of individual devices.
Types of devices:
The OS peripheral devices can be categorized into 3: Dedicated, Shared, and
Virtual. The differences among them are the functions of the characteristics of the
devices as well as how they are managed by the Device Manager.
1.Dedicated devices:-
Such type of devices in the are dedicated or assigned to only one job at a time
until that job releases them. Devices like printers, tape drivers, plotters etc.
demand such allocation scheme since it would be awkward if several users share
them at the same point of time. The disadvantages of such kind f devices s the
inefficiency resulting from the allocation of the device to a single user for the
entire duration of job execution even though the device is not put to use 100% of
the time.
2.Shared devices:-
These devices can be allocated o several processes. Disk-DASD can be shared
among several processes at the same time by interleaving their requests. The
interleaving is carefully controlled by the Device Manager and all issues must be
resolved on the basis of predetermined policies.
3.Virtual Devices:-
These devices are the combination of the first two types and they are dedicated
devices which are transformed into shared devices. For example, a printer
converted into a shareable device via spooling program which re-routes all the
print requests to a disk. A print job is not sent straight to the printer, instead, it
goes to the disk (spool)until it is fully prepared with all the necessary sequences
and formatting, then it goes to the printers. This technique can transform one
printer into several virtual printers which leads to better performance and use.
*****
Pipes
Pipe is a communication medium between two or more related or interrelated
processes. It can be either within one process or a communication between the
child and the parent processes. Communication can also be multi-level such as
communication between the parent, the child and the grand-child, etc.
Communication is achieved by one process writing into the pipe and other reading
from the pipe. To achieve the pipe system call, create two files, one to write into
the file and another to read from the file.
Pipe mechanism can be viewed with a real-time scenario such as filling water with
the pipe into some container, say a bucket, and someone retrieving it, say with a
mug. The filling process is nothing but writing into the pipe and the reading
process is nothing but retrieving from the pipe. This implies that one output
(water) is input for the other (bucket).

#include<unistd.h>

int pipe(int pipedes[2]);


This system call would create a pipe for one-way communication i.e., it creates
two descriptors, first one is connected to read from the pipe and other one is
connected to write into the pipe.
Descriptor pipedes[0] is for reading and pipedes[1] is for writing. Whatever is
written into pipedes[1] can be read from pipedes[0].
This call would return zero on success and -1 in case of failure. To know the cause
of failure, check with errno variable or perror() function.
Algorithm to write and read two messages using pipe:
Step 1 − Create a pipe.
Step 2 − Send a message to the pipe.
Step 3 − Retrieve the message from the pipe and write it to the standard output.
Step 4 − Send another message to the pipe.
Step 5 − Retrieve the message from the pipe and write it to the standard output.
Note: Retrieving messages can also be done after sending all messages.
Two-way Communication Using Pipes:
Pipe communication is viewed as only one-way communication i.e., either the
parent process writes and the child process reads or vice-versa but not both.
However, what if both the parent and the child needs to write and read from the
pipes simultaneously, the solution is a two-way communication using pipes. Two
pipes are required to establish two-way communication.

Algorithm: Achieving two-way communication using pipes.


Step 1 − Create pipe1 for the parent process to write and the child process to read.
Step 2 − Create pipe2 for the child process to write and the parent process to read.
Step 3 − Close the unwanted ends of the pipe from the parent and child side.
Step 4 − Parent process to write a message and child process to read and display
on the screen.
Step 5 − Child process to write a message and parent process to read and display
on the screen.
******
Buffer
The buffer is an area in the main memory used to store or hold the data
temporarily. In other words, buffer temporarily stores data transmitted from one
place to another, either between two devices or an application. The act of storing
data temporarily in the buffer is called buffering.
A buffer may be used when moving data between processes within a computer.
Buffers can be implemented in a fixed memory location in hardware or by using a
virtual data buffer in software, pointing at a location in the physical memory. In
all cases, the data in a data buffer are stored on a physical storage medium.
Most buffers are implemented in software, which typically uses the faster RAM to
store temporary data due to the much faster access time than hard disk drives.
Buffers are typically used when there is a difference between the rate of received
data and the rate of processed data, for example, in a printer spooler or online
video streaming.
Purpose of Buffering:
You face buffer during watching videos on YouTube or live streams. In a video
stream, a buffer represents the amount of data required to be downloaded before
the video can play to the viewer in real-time. A buffer in a computer environment
means that a set amount of data will be stored to preload the required data before
it gets used by the CPU.
Types of Buffering
1. Single Buffer:
In Single Buffering, only one buffer is used to transfer the data between two
devices. The producer produces one block of data into the buffer. After that, the
consumer consumes the buffer. Only when the buffer is empty, the processor
again produces the data.

2. Double Buffer :
In Double Buffering, two schemes or two buffers are used in the place of one. In
this buffering, the producer produces one buffer while the consumer consumes
another buffer simultaneously. So, the producer not needs to wait for filling the
buffer. Double buffering is also known as buffer swapping.

3. Circular Buffer :
When more than two buffers are used, the buffers' collection is called a circular
buffer. Each buffer is being one unit in the circular buffer. The data transfer rate
will increase using the circular buffer rather than the double buffering.
 In this, the data do not directly pass from the producer to the consumer because the data
would change due to overwriting of buffers before consumed.
 The producer can only fill up to buffer x-1 while data in buffer x is waiting to be consumed.

How Buffering Works:

In an operating system, buffer works in the following way:

Advantages of Buffer:

Buffering plays a very important role in any operating system during the execution of any process or
task. It has the following advantages.

 The use of buffers allows uniform disk access. It simplifies system design.
 The system places no data alignment restrictions on user processes doing I/O. By copying
data from user buffers to system buffers and vice versa, the kernel eliminates the need for
special alignment of user buffers, making user programs simpler and more portable.
 The use of the buffer can reduce the amount of disk traffic, thereby increasing overall system
throughput and decreasing response time.
 The buffer algorithms help ensure file system integrity.

******
Shared Memory
Shared memory system is the fundamental model of inter process
communication. In a shared memory system, in the address space region the
cooperating communicate with each other by establishing the shared memory
region. Shared memory concept works on fastest inter process communication.
If the process wants to initiate the communication and it has some data to share,
then establish the shared memory region in its address space. After that, another
process wants to communicate and tries to read the shared data, and must attach
itself to the initiating process’s shared address space.
Let us see the working condition of the shared memory system step by step.
Working:
In the Shared Memory system, the cooperating processes communicate, to
exchange the data with each other. Because of this, the cooperating processes
establish a shared region in their memory. The processes share data by reading
and writing the data in the shared segment of the processes.
Let us discuss it by considering two processes.
The diagram is shown below −

Let the two cooperating processes P1 and P2. Both the processes P1 and P2, have their different
address spaces. Now let us assume, P1 wants to share some data with P2.

So, P1 and P2 will have to perform the following steps −

Step 1 − Process P1 has some data to share with process P2. First P1 takes initiative and establishes
a shared memory region in its own address space and stores the data or information to be shared in
its shared memory region.

Step 2 − Now, P2 requires the information stored in the shared segment of P1. So, process P2 needs
to attach itself to the shared address space of P1. Now, P2 can read out the data from there.

Step 3 − The two processes can exchange information by reading and writing data in the shared
segment of the process.

Advantages

The advantages of Shared Memory are as follows −

 Shared memory is a faster inter process communication system.


 It allows cooperating processes to access the same pieces of data concurrently.
 It speeds up the computation power of the system and divides long tasks into smaller sub-
tasks and can be executed in parallel.
 Modularity is achieved in a shared memory system.
 Users can perform multiple tasks at a time.
*******

Operating System Security Policies and Procedures

Various operating system security policies may be implemented based on the organization
that you are working in. In general, an OS security policy is a document that specifies the
procedures for ensuring that the operating system maintains a specific level of integrity,
confidentiality, and availability.

OS Security protects systems and data from worms, malware, threats, ransomware, backdoor
intrusions, viruses, etc. Security policies handle all preventative activities and procedures to
ensure an operating system's protection, including steal, edited, and deleted data.

As OS security policies and procedures cover a large area, there are various techniques to
addressing them. Some of them are as follows:

1. Installing and updating anti-virus software


2. Ensure the systems are patched or updated regularly
3. Implementing user management policies to protect user accounts and privileges.
4. Installing a firewall and ensuring that it is properly set to monitor all incoming and
outgoing traffic.

OS security policies and procedures are developed and implemented to ensure that you must
first determine which assets, systems, hardware, and date are the most vital to your
organization. Once that is completed, a policy can be developed to secure and safeguard them
properly.

Operating System - Security

Security refers to providing a protection system to computer system resources such as CPU,
memory, disk, software programs and most importantly data/information stored in the
computer system. If a computer program is run by an unauthorized user, then he/she may
cause severe damage to computer or data stored in it. So a computer system must be
protected against unauthorized access, malicious access to system memory, viruses, worms
etc. We're going to discuss following topics in this chapter.

 Authentication
 One Time passwords
 Program Threats
 System Threats
 Computer Security Classifications
1.Authentication:

Authentication refers to identifying each user of the system and associating the executing
programs with those users. It is the responsibility of the Operating System to create a
protection system which ensures that a user who is running a particular program is authentic.
Operating Systems generally identifies/authenticates users using following three ways −

 Username / Password − User need to enter a registered username and password with
Operating system to login into the system.
 User card/key − User need to punch card in card slot, or enter key generated by key
generator in option provided by operating system to login into the system.
 User attribute - fingerprint/ eye retina pattern/ signature − User need to pass
his/her attribute via designated input device used by operating system to login into the
system.

2.One Time passwords:

One-time passwords provide additional security along with normal authentication. In One-
Time Password system, a unique password is required every time user tries to login into the
system. Once a one-time password is used, then it cannot be used again. One-time password
are implemented in various ways.

 Random numbers − Users are provided cards having numbers printed along with
corresponding alphabets. System asks for numbers corresponding to few alphabets
randomly chosen.
 Secret key − User are provided a hardware device which can create a secret id mapped
with user id. System asks for such secret id which is to be generated every time prior to
login.
 Network password − Some commercial applications send one-time passwords to user
on registered mobile/ email which is required to be entered prior to login.
********

PROTECTION
There are four levels at which a system must be protected:

1. Physical - The easiest way to steal data is to pocket the backup tapes. Also, access to the root
console will often give the user special privileges, such as rebooting the system as root from
removable media. Even general access to terminals in a computer room offers some
opportunities for an attacker, although today's modern high-speed networking environment
provides more and more opportunities for remote attacks.
2. Human - There is some concern that the humans who are allowed access to a system be
trustworthy, and that they cannot be coerced into breaching security. However more and more
attacks today are made via social engineering, which basically means fooling trustworthy
people into accidentally breaching security.
o Phishing involves sending an innocent-looking e-mail or web site designed to fool
people into revealing confidential information. E.g. spam e-mails pretending to be
from e-Bay, PayPal, or any of a number of banks or credit-card companies.
o Dumpster Diving involves searching the trash or other locations for passwords that
are written down. ( Note: Passwords that are too hard to remember, or which must be
changed frequently are more likely to be written down somewhere close to the user's
station. )
o Password Cracking involves divining users passwords, either by watching them type
in their passwords, knowing something about them like their pet's names, or simply
trying all words in common dictionaries. ( Note: "Good" passwords should involve a
minimum number of characters, include non-alphabetical characters, and not appear in
any dictionary ( in any language ), and should be changed frequently. Note also that it
is proper etiquette to look away from the keyboard while someone else is entering their
password. )
3. Operating System - The OS must protect itself from security breaches, such as runaway
processes ( denial of service ), memory-access violations, stack overflow violations, the
launching of programs with excessive privileges, and many others.
4. Network - As network communications become ever more important and pervasive in
modern computing environments, it becomes ever more important to protect this area of the
system. ( Both protecting the network itself from attack, and protecting the local system from
attacks coming in through the network. ) This is a growing area of concern as wireless
communications and portable devices become more and more prevalent.

******

Internal Access Authorization

Authorization is the process of giving someone permission to do or have something. In multi-user


computer systems, a system administrator defines for the system which users are allowed access to
the system and what privileges of use (such as access to which file directories, hours of access,
amount of allocated storage space, and so forth).

Assuming that someone has logged in to a computer operating system or application, the system or
application may want to identify what resources the user can be given during this session. Thus,
authorization is sometimes seen as both the preliminary setting up of permissions by a system
administrator and the actual checking of the permission values that have been set up when a user is
getting access.

 Authorization is a process by which a server determines if the client has permission to use a
resource or access a file.
 Authorization is usually coupled with authentication so that the server has some concept of
who the client is that is requesting access.
 The type of authentication required for authorization may vary; passwords may be required
in some cases but not in others.
 In some cases, there is no authorization; any user may be use a resource or access a file
simply by asking for it. Most of the web pages on the Internet require no authentication or
authorization.
Most web security systems are based on a two-step process. The first step is authentication, which
ensures about the user identity and the second stage is authorization, which allows the user to access
the various resources based on the user's identity. Modern operating systems depend on effectively
designed authorization processes to facilitate application deployment and management.

Key factors contain user type, number and credentials, requiring verification and related actions and
roles.

Access control in computer systems and networks relies on access policies and it is divided into
two phases:

1. Policy definition phase where access is authorized.


2. Policy enforcement phase where access requests are permitted or not permitted.

Thus authorization is the function of the policy definition phase which precedes the policy
enforcement phase where access requests are permitted or not permitted based on the previously
defined authorizations.

Access control also uses authentication to check the identity of consumers. When a consumer
attempts to access a resource, the access control process investigates that the consumer has been
authorized to use that resource. Authorization services are implemented by the Security Server
which can control access at the level of individual files or programs.
******

Android Operating System,

Android is a Linux-based operating system it is designed primarily for touch screens mobile
devices such as smartphones and tablet computers. The operating system has developed a lot in the
last 15 years starting from black and white phones to recent smartphones or mini computers. One of
the most widely used mobile OS these days is android. The android is software that was founded in
Palo Alto of California in 2003.

The Android operating system is a mobile operating system that was developed by Google (GOOGL
) to be primarily used for touchscreen devices, cell phones, and tablets. Its design lets users
manipulate the mobile devices intuitively, with finger movements that mirror common motions, such
as pinching, swiping, and tapping. Google also employs Android software in televisions, cars, and
wristwatches—each of which is fitted with a unique user interface.

Android is a powerful operating system and it supports a large number of applications on


Smartphones. These applications are more comfortable and advanced for users. The hardware that
supports android software is based on the ARM architecture platform. The android is an open-source
operating system that means that it’s free and anyone can use it. Android has got millions of apps
available that can help you manage your life one or another way and it is available at low cost in the
market for that reason android is very popular.
Features of Android Operating System:

Below are the following unique features and characteristics of the android operating system, such as:

1. Near Field Communication (NFC)

Most Android devices support NFC, which allows electronic devices to interact across short
distances easily. The main goal here is to create a payment option that is simpler than carrying cash
or credit cards, and while the market hasn't exploded as many experts had predicted, there may be an
alternative in the works, in the form of Bluetooth Low Energy (BLE).

2. Infrared Transmission

The Android operating system supports a built-in infrared transmitter that allows you to use your
phone or tablet as a remote control.

3. Automation

The Tasker app allows control of app permissions and also automates them.

4. Wireless App Downloads

You can download apps on your PC by using the Android Market or third-party options like
AppBrain. Then it automatically syncs them to your Droid, and no plugging is required.

5. Storage and Battery Swap

Android phones also have unique hardware capabilities. Google's OS makes it possible to upgrade,
replace, and remove your battery that no longer holds a charge. In addition, Android phones come
with SD card slots for expandable storage.

6. Custom Home Screens

While it's possible to hack certain phones to customize the home screen, Android comes with this
capability from the get-go. Download a third-party launcher like Apex, Nova, and you can add
gestures, new shortcuts, or even performance enhancements for older-model devices.

7. Widgets

Apps are versatile, but sometimes you want information at a glance instead of having to open an app
and wait for it to load. Android widgets let you display just about any feature you choose on the
home screen, including weather apps, music widgets, or productivity tools that helpfully remind you
of upcoming meetings or approaching deadlines.

8. Custom ROMs
Because the Android operating system is open-source, developers can twist the current OS and build their versions,
which users can download and install in place of the stock OS. Some are filled with features, while others change the
look and feel of a device. Chances are, if there's a feature you want, someone has already built a custom ROM for it.
Android Architecture

Android architecture or Android software stack is categorized into five parts:

1. linux kernel
2. native libraries (middleware),
3. Android Runtime
4. Application Framework
5. Applications

Let's see the android architecture first.

1) Linux kernel

It is the heart of android architecture that exists at the root of android


architecture. Linux kernel is responsible for device drivers, power management,
memory management, device management and resource access.

2) Native Libraries

On the top of linux kernel, their are Native libraries such as WebKit, OpenGL,
FreeType, SQLite, Media, C runtime library (libc) etc.
The WebKit library is responsible for browser support, SQLite is for database,
FreeType for font support, Media for playing and recording audio and video
formats.

3) Android Runtime

In android runtime, there are core libraries and DVM (Dalvik Virtual Machine)
which is responsible to run android application. DVM is like JVM but it is
optimized for mobile devices. It consumes less memory and provides fast
performance.

4) Android Framework

On the top of Native libraries and android runtime, there is android framework.
Android framework includes Android API's such as UI (User Interface), telephony,
resources, locations, Content Providers (data) and package managers. It provides a
lot of classes and interfaces for android application development.

5) Applications

On the top of android framework, there are applications. All applications such as
home, contact, settings, games, browsers are using android framework that uses
android runtime and libraries. Android runtime and native libraries are using
linux kernal.

*******

Android Development Frameworks


In general, the basic method of creating an Android app is to use Android Studio
(As it is the official IDE for Android). However, there are many other Android
Development Frameworks that are quite popular in and to provide you a little
variety, the list is given below…

1. Ionic
Ionic Framework is a very popular open-source mobile framework that was
released in 2013. It’s also free and MIT open source (so it will most probably
remain free!). According to its website, Ionic can be used to “Build and ship
beautiful cross-platform hybrid and Progressive Web Apps with ease.” And
that’s not all! Ionic is also a cross-platform framework, which means that you can
create apps and then customize them for Android, iOS, Windows, etc. Also, if you
have a problem with your documentation, fear not! Ionic has documentation
support with real-life examples.
2. Xamarin
Xamarin is an extremely popular Mobile framework(With over 1.4 million
developers using it!) that was acquired by Microsoft in 2016 and is currently a
Microsoft subsidiary. According to Xamarin, “Apps built using Xamarin look and
feel native because they are.” So basically, Xamarin can be used to write native
Android, iOS and Windows apps with a C# codebase (Xamarin is great for C#
developers!) that can also be shared across multiple platforms. Xamarin is also
popular (and only!) IDE with Microsoft Visual Studio and can be used to create
native apps with AutoComplete and IntelliSense.

3. Adobe PhoneGap
Adobe PhoneGap is an open-source mobile application development framework
that was purchased by Adobe Systems in 2011. Its unique feature is that it can be
used to build mobile applications using HTML5, CSS3, and JavaScript instead of
using API like Android, iOS, or Windows Phone. According to PhoneGap, it can be
used to “Reuse existing web development skills to quickly make hybrid
applications built with HTML, CSS, and JavaScript.”

4. React Native
React Native is an open-source mobile framework that was created by Facebook
and released in 2015. According to Mark Zuckerberg, “The biggest mistake we
made as a company was betting too much on HTML as opposed to native”
and that lead to the creation of React Native. It provides support for various IDEs
and mobile app development tools and that is one of the main reasons it is used
by many (popular!) companies such as Instagram, Tesla, Walmart, Baidu, etc. to
develop their mobile apps.

5. Flutter
Flutter is a comparatively recent open-source development framework that was
released by Google in 2017. According to Google, “Flutter is Google’s portable UI
toolkit for building beautiful, natively-compiled applications for mobile, web,
and desktop from a single codebase.” Flutter is written in the Dart
programming language (Also developed by Google) and it is currently used by
famous companies such as Alibaba, Tencent, Google (Of course!). Flutter provides
rendering support by using the 2D rendering engine Skia.

6. Titanium SDK
Titanium SDK is an open-source framework that was created by Appcelerator, Inc.
and released in 2018. (It’s quite new!) It is basically a development environment
that can be used to create native apps across various operating systems like iOS,
Android, BlackBerry, etc. Titanium is quite popular and has been used in around
70, 000+ Mobile Applications till now. And that’s not all! According to the
Titanium website “The Titanium environment helps organizations get to
market 60% faster and achieve a significant competitive advantage.”
7. JQuery Mobile
JQuery Mobile is a Touch-Optimized Web Framework that was developed by the
jQuery team and released in 2010. It is based on HTML5 and can be used to
create responsive web sites and apps that can be accessed using multiple devices
such as smartphones, tablets, desktops, etc. According to the jQuery team, this
takes the “write less, do more” mantra to the next level!!! In addition to that,
jQuery also provides support for different operating systems such as Windows,
Firefox, Mac OS, Blackberry, Kindle, etc.(So make your choice!)

8. Corona SDK
Corona Software Development Kit was developed by Corona Labs Inc. and released
in 2009. It is a great platform for creating apps for mobile as well as desktop
systems. Corona Labs states that “You can create your project once and
publish it to multiple types of devices, including Apple iPhone and iPad,
Android phones and tablets, Windows Desktop, etc.” Also, Corona is incredibly
fast as it is supported by Lua, an open-source scripting language that is
lightweight, fast, and powerful as well (Triple whammy!)

9. Native Script
Native Script is an open-source framework for creating native (duh!) mobile apps
that were developed by Progress and initially released in 2014. It was developed
using JavaScript and TypeScript (which is basically a superset of JavaScript).
Native Script also supports Angular and Vue.js frameworks and these can be used
to share existing web-based code. It also doesn’t hurt that Native Script is 100%
free and open source!

10. Mobile Angular UI


Mobile Angular UI is a mobile UI framework (As is clear from the name!) that
allows the creation of HTML5 hybrid mobile apps using a combination of Angular
JS and Bootstrap. According to the Mobile Angular UI website, “If you know
Angular JS and Twitter Bootstrap you already know Mobile Angular UI!!!” In
essence, Mobile Angular UI provides some components that are not available in
Bootstrap 3 such as switches, scrollable areas, sidebars, overlays, etc. and also
provides Angular.js directives to provide a better mobile experience.
******

Android Process Management

A process can be rightly thought as a program in execution. Generally to


accomplish a task, a process needs resources. For instance, CPU file, memory,
etc. Resources are allocated to processes in two stages i.e., the stage when process
was created or dynamically allocate the process while they are running.
Figure: Program in execution is known as process

A process is more than a coding or program of code; it includes current activity,


content of processor’s registers, etc. Program can be thought of as an passive
entity, process is an active entity. It contains a feature which is known as program
counter. Program counter is responsible for specifying the next instruction to be
executed. Word processor can be thought of as a process. So when we talk about a
passive entity it would be lika a file containing set of instructions saved on a disk
which is also known as executable file, whereas process ia meant to be an active
entity which is backed by a program counter which in turn specifies the next
instruction to be executed along with a set of associated resources. In other words
program converts into a process when it is loaded into memory. Following diagram
would depict the same statement pictorially which is as shown below:

Figure
Program and process

Structure of process in memory

Following diagram shows the structure of process in memory


Figure: Process in memory

Let us have a quick glance on these constituents of the process in memory and
they are:

 Stack: It contains temporary data such as parameters of function, return


addresses, and local variables.
 Heap: It is a memory that is dynamically allocated during process run time.
 Data: It includes global variables
 Text: It includes the current activity which is represented by the value of
program counter and the contents of the processor's registers.

States of process and Process Control Block (PCB)

Process State:

Just like liquid changes its state process too changes its states during execution.
Major transition states of process are namely:

 New: Process is created


 Running: Instructions are executed
 Ready: Process is ready to get executed and is waiting to get assigned to
processor
 Waiting: Any event of line need to be performed hence process is waiting for
that event to occur
 Terminated: Execution or process is accomplished

The states that they represent are found on all systems but certain operating
systems also more finely delineate states of process. The names may vary
according to different operating systems. There can be more than one process
which are in ready or waiting state but at any instant of time one and only one
process can be in running state at one processor. Pictorial representation of
process states is as follows:

Figure Process states


PROCESS CONTROL BLOCK (PCB)

You must be thinking there are so many processes and how are they going to be
represented in operating system well, we have process control block which
uniquely represents each process in operating system. It is also called task control
block. PCB contains associated information which is as follows:

 Process state: A process can be in new, ready, running, etc.


 Program counter: It contains address of next instruction to be executed.
 Registers: CPU registers include accumulators, index registers, stack
pointers, and general-purpose registers. It also includes condition-code
information. The number of registers and their type may be different in
different architecture.
 Memory management: It also includes information about memory
management. Depending on the memory system used by the operating
system it may include information such as the value of the base and limit
registers, the page tables, or the segment tables.
 CPU-Scheduling system: It includes information such as priority of process,
scheduling parameters, pointers to scheduling queues, etc.
 Accounting information: This overtures the information like time limits,
amount o CPU and real time used, job or process numbers, account
numbers, etc.
 I/O status information: It includes information like list of IO devices, list of
open files, etc.

Figure: Process Control Block (PCB)

Android and interprocess communication

Android can host variety of applications and it is designed in a way which removes
redundancy or duplication of functionalities in different applications or to allow
functionality to be discovered, etc.

There are two major techniques related to interprocess communication and they
are namely;
 Intents: These enable an application to select an Activity based on the
action you want to invoke and the data on which they operate. Hardcoded
path to an application is needed to use its functions and exchange data with
it. With intent objects data can be used t pass objects in both directions. It
enables a high-level interprocess communication.
 Remote methods: By this we mean the remote procedure calls (RPCs) with
this APIs can be accessed remotely. With remote calls, the methods appear
to be local which are executed in another process. Android Interface
Definition Language (AIDL) is used for this purpose.

Android applications avoid interprocess communication. It provides functions in


packages loaded by applications that require them. For applications to exchange
data applications need to use file system or other traditional Unix/Linux IPC
mechanisms,

******

Android File System

Under the Android file system, there are usually six main partitions found on
every device. Some devices may come with a couple of additional partitions, those
differ from model to model, but there are six primary partitions that are found on
every single Android device. These include /boot, /system, /recovery, /data,
/cache, and /misc. Additionally, for external Android smartphone, there are two
file system partitions – /sdcard and /sd-ext. So, let’s break down each partition
separately and explore the Android File system hierarchy.

/boot

This partition consists of the Android kernel and the ramdisk. Basically, every
single thing that is needed to boot your Android device when powered on. You
should only proceed to wipe this partition from recovery if it is absolutely
necessary. If you do, once the partition is wiped, ensure to reboot the phone only
after installing a new boot partition. The new partition can be a /boot partition
found in a ROM.

/system

The system partition accommodates the entire Android OS. This includes the
Android GUI as well as the system apps that come pre-installed on Android
devices. So, what happens if you wipe this partition? Well, you can still boot the
device. We will only be able to put our device into recovery or bootloader mode.
/recovery

This partition is designed for backup and can be considered the alternative boot
option or partition in an Android device. It lets the device boot into recovery mode
where backing up data, wiping data, restoring phone to factory settings, and
performing other maintenance operations.

/data

Also known as user data partition, this partition consists of all of the user’s data,
including contacts, settings, apps and messages. Wiping the data partition will
lead to storing your phone to factory settings, having removed all of the apps,
messages, and user settings from the Android device.

/cache

This partition stores the frequently accessed app data and components. Wiping
this partition will just clear the built-up cache, and the device will simply go back
to rebuilding it as you continue using it. Clearing cache also frees up some space
in your device and can also fix certain issues at times.

/misc

This partition contains all the miscellaneous system settings, usually on/off
switches. The settings may include carrier or region ID, USB configuration, and
certain hardware setting. This partition is very important since it can cause
several device features to malfunction if the partition becomes corrupt or goes
missing. A missing /misc partition can also cause the Android device to not boot
at all.

/sdcard

This partition is the space that is available to users to store their files and data.
Depending on your device, you could even have more than one sdcard partition. If
your device has an external SD card slot, then the /sdcard partition refers to the
internal storage device, and the external SD card will be assigned a different
partition, either a new partition called /sdcard2 or a separate directory within the
/sdcard partition itself such as /sdcard/sd. Wiping the partition with the external
SID card storage is completely safe, as long as you have backed up any important
data or documents you may have on it. Wiping the /sdcard partition with the
external SD and storage is completely safe, as long as you have backed up any
important data or documents you may have on it. Wiping the /sdcard partition,
however, results in wiping some system and app data and settings, but it still
doesn’t hinder the system’s boot processor functionality.
/sd-ext

This is an additional partition of the sdcard partition, which is only present on


some devices, typically ones that have custom ROMS or mods on them. It can
usually be used with certain ROMS that have special features such as APP2SD+
or data2ext enabled. This is essentially a /data partition of the /sdcard and stores
some user data and settings that are typically stored on the /data partition. This
is useful for devices with limited internal memory.

Without rooting your device, Android users typically can only access the data
partition. The contents of this partition are what you will see in most file
managers or when you connect it to a PC. If you have an external SD card
attached to the device, you will also be able to view the contents of it in this user-
accessible data partition. If your phone doesn’t come packing a decent file explorer
or manager, you can simply install one of the powerful third-party file manager
available on the Play Store. You can also browse your data files onPC via a USB
connection. However, ensure that your phone is in MTP (Media Transfer) or File
Transfer mode.

Android also divides its storage into three distinct categories, which is quite
different from a PC’s file system layout. Here is how it divides its storage:Device
storage – This refers to the pool of storage you can work with and access. You can
even modify files in this storage area.Portable SD card storage – This storage
area is allocated to external SD cards. You can load files into this and then insert
them into your device.Device root storage – Every Android device has a special
file system where all the root files are stored. This includes operating system files,
sensitive application data, system apps, and more. Users typically cannot modify
this file system for security and device safety reasons unless, of course, they have
root access.
In the most basic sense, ‘root’ refers to the topmost folder in the Android file
system. This would be the equivalent to the c:\ drive on Windows. Unlike
Windows, though, Android has built an invisible barrier about halfway up the file
system tree and only allows you to access certain files before you hit this virtual
wall, beyond which the root files lie. This is to stop users from making irreversible
or irreparable changes to critical OS files.

*******

You might also like