July 20, 2018

Real Time Operating System Importance - Important QnA


Text Books
T1 Liu, Jane W.S., Real Time Systems, Pearson Education, 2000
T2 Laplante, Phillip A., Real-Time Systems Design and Analysis, Wiley, 3rd Ed., 2004
T3 Jared Hendrix, Raspberry Pi: Essential guide on starting your own raspberry pi3 projects with ingenious tips and tricks
T4 Arshdeep Bahga, Vijay Madisetti, Internet Of Things A hands on Approach


 

Question.1
Design a Biometric Facial Authentication device for a small company of 25 employees. The device should be capable of Enrolling and verifying the face. If the face matches then allow access into the company. The enrollment of New Ids should be stored in the organization database server and the ex-employees access should be denied.Draw the block diagram including the Components required for the design.List out the tasks: periodic, aperiodic and sporadic tasks of the system. Which scheduling algorithm should be used. Illustrate the same with an example. 

Answer:

Components required:




Periodic tasks
LCD  display 
Reading data base till match is found or END of database- 

Aperiodic Task
Face sensing through sensor 
Temporary storing of minutiae points from the image 
Matching the temporary image and database image 
Allowing access into organization(ex: opening of gate etc)

Sporadic tasks: None

Clock driven scheduling algorithm using the above parameters.

Question. 2
Consider a task set comprising of 5 tasksT(e,d) T1(13,20), T2(12,30), T3(18,40), T4(15,50) and T5(14,60) to be scheduled on 2 processors. Which scheduling strategy would ensure tasks get an optimal share of resources. The resource actually consumed is 20% (rounded off to the nearest integer). Assume the first task starts at 0.Construct the schedule and obtain the makespan.

 Answer:

The algorithm for Optimal utilization is Uniform Laxity based method as it uniformly dispenses slack improving resource allocation.

Minimum execution time = 20% of Actual execution time
Min 1 =0.2*13=2.6 = 3 (approx)
Min2= 0.2*12=2.4 = 2(approx)
Min3=0.2*18=3.6=4 (approx)
Min4=0.2*15=3(approx)
Min5=0.2*14=2.8=3(approx)

Laxity = (deadline –(current time +minimum execution time))
L1=(20-(0+3))=17
L2=(30-(20+2))=8
L3=(50-(40+3))=7
L4=(60-(50+3))=7
L5=(30-(25+2))=3
Average Laxity=9

Time utilized =Min exec time + Average Laxity
TU1=3+9=12
TU2=2+9=11
TU3=4+9=13
TU4=3+9=12
TU5=3+9=12

Slack Available = WCET-Time Utilised
S1=13-12=1
S2=12-11=1
S3=18-13=5
S4=15-12=3
S5=14-12=2


Makespan on P1= 12+11 = 23 units
Makespan on P2= 13+12+12 = 37 units

Question. 3
Draw petrinet model for vending machine, The machine dispenses two kinds of snack bars – 20c and 15c.
Only two types of coins can be used – 10c coins and 5c coins. The machine does not return any change.


Answer:
3 scenarios can be considered,
  Scenario 1: 
Deposit 5c, deposit 5c, deposit 5c, deposit 5c, take 20c snack bar.

  Scenario 2:
Deposit 10c, deposit 5c, take 15c snack bar.

  Scenario 3:

Deposit 5c, deposit 10c, deposit 5c, take 20c snack bar.


Question. 4
Given seven tasks, A, B, C, D, E, F, and G, construct the precedence graph from the
following precedence relations:.
A → C
B →C B→ D
C →E C→ F
D →F D→ G
Then, assuming that all tasks arrive at time t = 0, have deadline D = 25, and computation
times 2, 3, 3, 5, 1, 2, 5, respectively, modify their arrival times and deadlines to schedule
them by EDF.

Answer:

The precedence graph is shown below:









Question. 5
Let us consider an automatic car body painting machine has two robotic arms R1 and R2. The real time system that is responsible for paint operation has five different processes P1, P2, P3, P4 and P5. The release time and CPU burst time of each process is ri=(7, 5, 4, 2 and 0) and ei=(3, 3, 2, 6 and 6) respectively. The process P1 requires the robotic arm R1 for duration of 1 unit of time and it is required at time 8. Similarly the process P2 and P5 needs another arm R2 at time 6 and 1 respectively. The process P2 and P5 needs those resources for a period of 1 and 4 unit of time respectively. However, the process P4 required both the robotic arm R1 and R2 for a period of 4 and 1.5 unit of time and at 3 and 9 unit of time. The priority of the process varies with its number i.e. P1 has maximum and P5 has minimum priority. Now schedule those processes by considering the priority ceiling protocol. Determine that if there is any process will be blocked because of resource conflict also find the time of block. Also draw the time line diagram illustrating the above example. Assume you have only one CPU and the robotic arm are non-pre-emptible.

Answer:



July 18, 2018

Important QnA on Multimedia Computing - Comprehensive


Text Books

T1 Ze-Nian Li & Mark S. Drew, "Fundamentals of Multimedia", Pearson Education, 2004


Question.1 
Explain the difference between Temporal and Frequency masking.

Answer:
Frequency Masking: When an audio signal consists of multiple frequencies the sensitivity of the ear changes with the relative amplitude of the signals. If the frequencies are close and the amplitude of one is less than the other close frequency then the second frequency may not be heard. 

Temporal masking
  • After the ear hears a loud sound, consisting of multiple frequencies, it takes a further short while before it can hear a quieter sound close in frequency.
  • Temporal Masking accomplished 50% overlap between consecutive transform windows and then relating frequency masking.
  • MPEG Audio encrypts frequency masking by quantizing each filter bank with adaptive values from nearby bands, defined by a look up table.
Question. 2
Consider the following set of protocols (SIP, RTSP, RSVP, RTCP, RTP on top of UDP. If you want to design a protocol stack (control and data plane) for Video‐On‐Demand (VOD) service between client and server, (a) which protocols would you use and why, and (b) in which order would you apply your selected protocols? Explain how the protocol stack of selected protocols would be used ?

Answer:
To design the Video‐On‐Demand service,
RTP protocol : for transmission of the video . RTP/UDP enables real‐time transmission. 
RTCP : The accompanying control protocol for RTP is the RTCP that would allow the receiver to provide feedback to the sender if some parameters need to be adjusted during the streaming session. 
RTSP : Since VOD will use commands such as play, stop, pause, fast forward, rewind, so anyone should use the RTSP protocol because it specifies signaling for completing these control tasks between the client and the server.
RSVP: If an IP level also requires the built-in reservation capabilities of VOD traffic, it is important to enable the RSVP protocol to start integrated Guaranteed Services using the RSVP Reservation Protocol.
 
RSVP to reserve bandwidth for the VOD session. 

Once the resources are reserved, VOD traffic should be transmitted via RTP which is on top of UDP/IP. 


Along with this, RTP RTCP and RTSP should provide (1) RTP (Control) to provide control feedback about the status of traffic and receiver, and (2) controlling the channel through signaling (RTSP) control , Stop, and otherwise control the VOD playback.

Question. 3
Compress the string “DEAF!DEFEATED” using LZW algorithm. Find compression ratio by

supposing that originally the characters are represented in 8-bit (B=66, A = 65, ,., Z = 90, Y = 89, , ! = 33).

Answer:
Input: DEAF!DEFEATED

Previous
Current
Output
Code
String

065
A
068
D
069
E
070
F
084
T
033
!
D
E
068
256
DE
E
A
069
257
EA
A
F
065
258
AF
F
!
070
259
F!
!
D
033
260
!D
D
E



DE
F
256
261
DEF
F
E
070
262
FE
E
A



EA
T
257
263
EAT
T
E
084
264
TE
E
D
069
265
ED
D
End Of File
068



The compressed output is 068 069 065 070 033 256 070 257 084 069 068
Compression ratio = 13/11 = 1.18181

Question:
Compress the string “PROPER_PROPERTY” using LZW algorithm by using codeword of 10 bit. Find compression ratio by assuming that originally the characters are represented in 8-bit (A = 65, B=66... Y = 89, Z = 90,  _ = 95).

Answer

Input: PROPER_PROPERTY
                                               
S
C
Output
Code
String

069
E
079
O
080
P
082
R
084
T
089
Y
_
95
P
R
080
256
PR
R
O
082
257
RO
O
P
079
258
OP
P
E
080
259
PE
E
R
069
260
ER
R
_
082
261
R_
_
P
095
262
_P
P
R



PR
O
256
263
PRO
O
P



OP
E
258
264
OPE
E
R



ER
T
260
265
ERT
T
Y
084
266
TY
Y
NULL
089




The compressed output is 080 082 079 080 069 082 095 256 258 260 084 089

July 05, 2018

Big Data - HDFS Overview


HDFS(Hadoop Distributed File System):
HDFS is a distributed file system, It's specially design for storing huge data set with cluster(group of hardware) of commodity hardware through streaming access pattern. HDFS is highly fault-tolerant and is designed to be deployed on low-cost hardwares.

Streaming access pattern -> "write once , read n number of times but don't change content of file".

Hadoop daemons:

Hadoop 1.0

Master- NameNode, JobTracker, Secondary NameNode,
Slave-    DataNode, TaskTracker

Hadoop 2.0

Master - NameNode, Secondary NameNode, Resource Manager
Slave -    DataNode, Node manager.

IMP: To store data what are the services we need:- NameNode(to create metadata), DataNode(to store actual data).
IMP: To process data:- JobTracker and TaskTracker.

Single Point of failure:

Hadoop 1.0:- The NameNode is the single point of failure. Each cluster has a single NameNode and if that machine is not available, the whole cluster will not be available.

Hadoop 2.0:- HDFS comes with high availability which overcome the single point of failure by providing an option to run two NameNodes in the same cluster as an Active/Passive configuration with a hot standby.


NameNode and DataNode:

HDFS has the NameNode and DataNode as known as Master/Slave. The NameNode contains Metadata and perform operations like opening, closing, and renaming files and directories. The DataNode is responsible for serving request from client's system. It also performs block creation, deletion, and replication upon instruction from the NameNode. HDFS is built using java language and because of java portability, it can deployed/run on wide range of machines.

Data Replication:

HDFS is designed to store large volume of data across machines in a large cluster. It stores each files as a sequence of blocks and the blocks of files are replicated to overcome with fault-tolerance. We can set the block size and the replication factor manually by changing in hdfs-site.xml file which usually found in the conf/ folder of the Hadoop installation directory. Once you are in the conf/ folder, find the below properties to make any change in that.

<property> 
<name>dfs.replication<name> 
<value>3<value> 
<description>Block Replication<description> 
<property>

hdfs-site.xml is used to configure the HDFS and any changes made in this file would be default replication for all the files placed in HDFS. We can perform replication factor on a per file basis also by using the below shell command.

> hdfs dfs -setrep -w 2 /user/cloudera/training/userdata.txt    [This shell command will set the replication 2 for the file userdata.txt]

IMP: What is the default replication factor(default value in HDFS) -> 3 which means for each block stored in HDFS will have 1 original block and 2 replicas.

Architecture:

Block size in HDFS

The default block size in Hadoop 2.0 is 128MB and earlier it was 64MB for the Hadoop 1.0, This is used to divide the input file into blocks and distribute those blocks across the cluster.  For example: if the input file size is 170MB which is put into HDFS and the default block size in Hadoop 2.0 is 128MB then, HDFS would split the file into 2 blocks which would be as of 128MB each. The first block will have 128MB and the other block will have 42MB space(Remaining space will be available for OS which is 86MB).

If we want to change the default size of block in HDFS so it can be via hdfs-site.xml. It will change the default block size for all the files placed into HDFS.

<property> 
<name>dfs.block.size<name> 
<value>134217728<value> 
<description>Block size<description>
<property>

IMP: Changing the block size in HDFS will not affect any files currently available in HDFS, it will only affect the file which is placed after the setting has taken effect.
IMP: Why 128mb of block size, why not 128kb of block size-> For each block in HDFS , we need to create metadata in namenode so if we go with 128kb of block size then it will have to create more metadata for every blocks.

Metadata:
What do you means by Metadata ? . It's the additional information about our data, Like - Number of input splits, number of replication, data block location, file size etc. HDFS namespace is stored by the NameNode. The NameNode uses a transaction log called EditLog to keep update the record when every change occur in the files system.

There are 2 importaint files:
1. FsImage
2. EditLog
Metadata is kept on highly configured system as NameNode, It keeps an image of entire file system through FsImage and EditLog transactions. The FsImage would have data of a file from pre one hour data to its started execution time whereas EditLog has the latest one hour data
When the NameNode starts up, it reads the FsImage and EditLog from the disk. All the latest data flushes out from EditLog to FsImage and It can truncate the old EditLog because the transactions has been applied to FsImage. This process is called Checkpoints.
Data Node stores HDFS file in its local file system and doesn't have any knowledge about HDFS files. It stores HDFS files in separate local file system to overcome with data loss. Data Node keeps sending Heartbeat to NameNode after specific time interval. It scans through its local file system, generates a list of all HDFS data blocks that correspond to each of these local files and sends this report to the NameNode: which is known as Blockreport.

Difference between Hadoop 1 vs Hadoop 2: 
The biggest difference between both is YARN technology. YARN stands for Yet Another Resource Negotiator. YARN has 2 daemons which take care of 2 tasks - JobTrackera and TaskTracker. 
In Hadoop 2.0, JobTracker and TaskTracker has been replace by Resource Manager and Node Manager. 
Resource Manager: It allocates resources to various applications.
Node Manager:   It monitors the execution of the process.