Assume that the head starts at track 20.
b.Calculate the total number of tracks and the average number of tracks travelled by the head to satisfy the requests in B-Q1-a
2.a.What is a race condition? Explain race condition with an example (do not use the example from the lecture slide). Use your own example and explain in your own words.
b.Consider a system with four dedicated resources and four processes (process P1, P2, P3 and P4) that require a maximum of two devices to complete a task. Draw a directed graph of the scenario that demonstrates there is a deadlock in the system. Explain your graph with details.
c.I. Files can be formatted with fixed-length or variable-length fields. Explain them in your own words with example
II. Explain relative and complete file name in your own words with example
Head starts at track 20.
Total no of track = |35-20|+|35-1|+|27-1|+|27-2|+|11-2|+|11-18|+|60-18|+|60-23|
Total no of tracks= 0-60=61
Total No of tracks = |20-18|+|23-18|+|27-23|+|35-27|+|35-11|+|11-2|+|2-1|+|60-1|
Total n o of tracks= |20-18|+|18-11|+|11-2|+|2-1|+|23-1|+|23-35|+|35-60|
Race round condition:
Race round condition is the special condition happens in the critical section. The code in the critical section can be accessed by the multiple thread . The race round condition defines that condition where two or more threads want to read or write on the shared data and the final data depends on who runs precisely.
Two or more threads want to access the same shared data will lead to the happening of the race round condition. Suppose, thread A and the thread B shared the variable which is count by 1. Thread A increases the count of 1 while thread B decreases the count of 1 . Now, if the count value is 10, the difference operation will yield different result of the count and this can be happened if the count is not protected using the mutual exclusion. In case if both the statements are not protected, while thread A will execute the operation on the count A , the system may switch to execute to the thread B. In this case the problem may arise.
There are four resources and the four processes. Let, p1,p2,p3,p4 are four processes and four resources are r1,r2,r3,r4.
In this picture there are four resources available along with the four processes. The process P1 requests the resources from R1 is providing the resource to the P2. R3 is also providing the resource to the P2.R3 is providing the resource to the P1. P3 is taking resources form the R3 and R2. P4 is taking the resource from R2. The resource R4 is not accessed by the any process. In the entire system the cycle is present so it can be said that the deadlock is present.
Fixed length file formatting:
In fixed length file formatting system the text files are formatted by the specified pad characters, left and right alignment and the column widths. In this case, each paragraph or the rows has the one complete record. Each row can contain many pieces of the data. Within the each column the data is padded with the spaces. The data can be aligned to left to the right. The number of characters used in the each column has same character and the alignment.
There are 2o characters in the first column and alignment is left. The data contains in it is the NAME.
Second column contains the 10 characters and is left aligned. It contains the information about the STATE.
Variable length file formatting:
In case of the variable length file format, the file can use a length prefix. It mean that they contain prefix which helps to identify the length of the record.. Each of the record contains the length of the record. The length of the record must be in the prefix of the record and it is the 16 bit binary number which includes the prefix of the 2 byte length. The separator is used in the variable length file formats.
The relative file name contains the relative key, which is a record number that represents the location and the reference from where the file begins . The transmission modes for in the relative file are sequential , dynamic and random. The relative record number works in maintaining the sequence.
The file in the first record has the relative number 1, the tenth file in the record has the record number of 10.The length of the records can be of the fixed and the variable length.
The complete file is associated with the inclusion and driver letter in the Linux.
Brief introduction of the function: This command is used for the searching of the regular expression against a text . This command is used in the linux which can deals with the multiple files and the stream of output. The main function of the this command is to search the specified text in the line. There are three variations of the grep syntax- egrep,fgrep,rgrep.
The basic syntax : in a file named ‘rain’ in which it is written “It is raining. Raining makes the day dull”.
In case if the ‘raining’ is needed to be searched.
$ grep “raining” rain
Syntax: grep “string _to_be_searched” filename
The other two options of the grep command are egrep and fgrep.
Chmod: In Linux operating system eaxh of the files ahs some set of rules, which are associated with the access of the file . These rules are called file modes.chmod operation can change the modes of the files.
Syntax: chmod options permissions filename
Example: chmod 754 filename.
4 is equivalent to “read”
2 is equivalent to “write”
1 is equivalent to “execute”
0 is equivalent to “ no permission”
Here 7 is the combination of 4+2+1 =7 (read, write and execute)
There are some of the options available in the chmod command- they are
-f= quiet mode
-v= verbose mode.
Wc: wc represents the word count in the newlines . The function of the wc prints the newline, byte and the word for the each file. Wc represents the standard input.
There are various options available in the wc options-
-c,--bytes= prints the byte code
-m,--chars= print the count of the character.
-l,--lines= print the count of the newline.
Is: It shows the list of the contents in the directory.
Syntax: ls [option]------[File]
There are various options available for the ls. Some of them are
-a,--all= not ignoring the entries starting with .
--author= with –l, author name is needed to be printed for the each line.
-b,--escape=printing of the octal escape of the characters which are non graphic in nature.
Eslamimehr, Mahdi, and Jens Palsberg. "Race directed scheduling of concurrent programs." In ACM SIGPLAN Notices, vol. 49, no. 8, pp. 301-314. ACM, 2014.
Lee, Changman, Dongho Sim, Joo Young Hwang, and Sangyeun Cho. "F2FS: A New File System for Flash Storage." In FAST, pp. 273-286. 2015.
LaForest, Mark. "Automatic administration of UNIX commands." U.S. Patent 9,268,608, issued February 23, 2016