Introduction to Operating Systems - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Introduction to Operating Systems

Description:

rand() Generate a random number in range [a, b] (int)(((double)rand() / ((double)RAND_MAX (double)1)) * (double)(b - a 1)) a; ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 17
Provided by: l26645
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Operating Systems


1
Introduction to Operating Systems
  • Project 3, Recitation 3
  • Fan Wu
  • fwu2_at_cse.buffalo.edu
  • www.cse.buffalo.edu/fwu2/

2
Problem 3 Addendum
  • Recognizing starting and ending point of commands
  • Combine all the commands in a single stream
  • R_1_1_R_2_2_W_1_2_5_ABCDE_R_1_2_
  • Using Start Request T 1 and End Request T 2
    command
  • T 1
  • R 1 1
  • R 2 2
  • W 1 2 5 ABCDE
  • R 1 2
  • T 2

3
Problem 3 Addendum (contd)
  • Padding unfilled bytes
  • Using \0, or say null character
  • W 2 2 5 ABCDE
  • ABCDE\0\0\0
  • W 2 2 256 ABTRCYNM
  • ABTRCYNM

251 \0
256 characters
4
Problem 3 Addendum (contd)
  • How to use random generator?
  • Include header ltstdlib.ingt
  • Initialize
  • srand (unsigned int seed)
  • Generate a random number in range 0, RAND_MAX
  • rand()
  • Generate a random number in range a, b
  • (int)(((double)rand() / ((double)RAND_MAX
    (double)1)) (double)(b - a 1)) a

5
Dealing with Errors
  • Error Could not open file mydisk
  • File mydisk has permission ---------- after
    using
  • open(mydisk , O_RDWR O_CREAT, 0)
  • Solution
  • chmod 644 mydisk
  • -rw-r--r-- 1 fwu2 csgrad 25600 Nov 10 0549
    mydisk

6
Dealing with Errors
  • Error Address already in use
  • gtps a
  • gtkill process
  • Wait 30 seconds
  • Try again

7
Problem 4
  • The Intelligent disk-storage system IS problem
    3 with the addition of a disk scheduler.
  • You are required to implement
  • FCFS First Come First Serve
  • SSTF Shortest Seek Time First
  • C-LOOK go to last requested cylinder from
    current cylinder, then snap back to the lowest
    request cylinder

8
Problem 4 (contd)
  • Four ways to call different schedulers
  • Open 3 ports on server, the first port to handle
    FCFS, the second port to handle SSTF, and the
    third port to handle C-LOOK
  • Pass another command line parameter 1 for FCFS,
    2 for SSTF, 3 for C-LOOK
  • Create 3 different disk servers, i.e. compile
    each one separately (Not preferred)
  • Pass another parameter from the client program,
    i.e., use "A 1" for FCFS, "A 2" for SSTF, "A 3"
    for C-LOOK. Return 1 if success, or 0 if failure

9
Problem 4 Demo Run
  • Server
  • ./IDS
  • Usage ./IDS ltFilenamegt ltCylindersgt ltSectorsgt
    ltTrackToTrackSleepTime(ms)gt ltcachesizegt
    ltschedulergt
  • Scheulers 1 -- FCFS
  • 2 -- SSTF
  • 3 -- C-LOOK
  • ./IDS mydisk 10 10 100000 8 2
  • Random data client
  • ./DCRD
  • usage ./DCRD ltserverAddrgt ltNgt ltRandomSeedgt
  • ./DCRD localhost 40 2

10
Problem 4 Demo Scripts
  • Server side

Receive I Processing command(s) I Reply 10
10 Receive W 8 0 10 DJKSBPQZHH R 9 3 R 9 8 R 5
5 W 1 3 10 XWICBQUWTY R 1 6 R 7 2 R 0 5 R 9 9 W 9
7 10 YOIUTSRPAT W 6 5 10 NKMSODZIKG R 9 5 R 8 2
W 6 4 10 VYBFQSFQNB Processing command(s)
R W R R R R R W Processing command(s) W R W R R
W W R Processing command(s) R R R W W R R
W Processing command(s) R R W W W R R
W Processing command(s) W R R R R W W W Reply
111AGBLEJBODW1111IHOHFFYVMQ111111111QRPGRJXJYK1XSR
HJUTFLH1111111111111kkkkkkllll1111XSRHJUTFLH11QRPG
RJXJYK1COEPLDJXJI111
11
Problem 4 Demo Scripts
  • Client side

Using chars 2 Sending I Client requested
'I' and got back cylinders10 and
sectors10. Client is sending 40 random
requests. Using chars 478 Sending W 8 0 10
DJKSBPQZHH R 9 3 R 9 8 R 5 5 W 1 3 10 XWICBQUWTY
R 1 6 R 7 2 R 0 5 R 9 9 W 9 7 10 YOIUTSRPAT W 6 5
10 NKMSODZIKG R 9 5 R 8 2 W 6 4 10 VYBFQSFQNB
Client recieved the following
responses... 1111111111111111111111111111111111111
111 Executable time for 40 random RW requests is
8067304 microseconds. Exiting Random data
client.
12
Plotting
  • MS Word
  • Insert --gt Picture --gt Chart
  • Latex
  • Gnuplot
  • http//www.gnuplot.info/
  • Matlab

13
Problem 5 File System Server
Basic / Intelligent Disk Server
server
client
File System Server
Test Client
server
client
14
Problem 5 File Allocation Table
N lt Cylinder Sector
15
Problem 5 Command Types
  • Commands that do not need disk operation
  • F, C, D, L
  • Commands that need disk operation
  • R, W, A

16
Problem 5 Demo Run
  • Server
  • ./BDS mydisk 10 10 100000
  • ./FS
  • Usage ./FS ltDiskServerAddressgt
  • ./FS localhost
  • Client
  • ./FC
  • Usage ./FC ltServerAddrgt
  • ./FC localhost
  • F
  • C file1
  • C file2
  • L 0
  • W file1 5 ABCDE
  • A file2 6 FGHIJK
  • L 1
  • R file2
  • D file1
  • L 1
  • exit
Write a Comment
User Comments (0)
About PowerShow.com