in Operating System edited by
30,048 views
80 votes
80 votes

Consider a hard disk with $16$ recording surfaces $(0-15)$ having $16384$ cylinders $(0-16383)$ and each cylinder contains $64$ sectors $(0-63)$. Data storage capacity in each sector is $512$ bytes. Data are organized cylinder-wise and the addressing format is $\langle \text{cylinder no.}, \text{surface no.}, \text{sector no.} \rangle$ . A file of size $42797$ KB is stored in the disk and the starting disk location of the file is $\langle 1200, 9, 40\rangle$. What is the cylinder number of the last sector of the file, if it is stored in a contiguous manner?

  1. $1281$
  2. $1282$
  3. $1283$
  4. $1284$
in Operating System edited by
by
30.0k views

4 Comments

@priyanshu.jha 

 I hope you know difference between a cylinder and a track..

I like your confidence here 
cause ...gatecse is the creator of this site

and your link was helpful for me thanks!!

0
0

Each cylinder contains 64 sectors ⟹ at each surface within the cylinder there are 64 sectors

0
0
 Important point that should also be noted here

 

1
1

10 Answers

246 votes
246 votes
Best answer
First convert $\langle 1200,9,40\rangle$ into sector address.

$(1200  \times  \mathbf{16  \times 64}) + ( 9 \times  \mathbf{64}) + 40 = 1229416$

Number of sectors to store file $= (42797 \ KB) / 512 = 85594$

Last sector to store file $= 1229416+85594=1315010$

Now, do reverse engineering,

$1315010/(\mathbf{16 \times 64})=1284.189453$ $(1284$ will be cylinder number and remaining sectors $=194)$

$194/\mathbf{64} = 3.03125$  $(3$ is surface number and remaining sectors are $2)$

$\therefore \langle 1284,3,1\rangle$ is last sector address.

Correct Answer: $D$
edited by
by

32 Comments

how you got 194 as a remaining sector
4
4
Cylinder number =1284.189453

We took 1284 as cylinder number, in that fractional portion is. 189453,which is multiplied by total surfaces and 64 sectors per cylinder

0.189453*16*64=194
27
27
ok got it...so after that how u calculated sector number=2,remaining fraction is 0.03152 then what u have done???did u multiply by 64.
0
0
multiply 0.03125 with 64 i.e. number of sectors in each cylinder (as we hv got cylinder number of our file ,now we have to get surface number in that cylinder ,hence multiply the fractional part with 64)
2
2
thanks..got it
0
0
since remaining sectors are 2, so sccording to me , the address of last sector should be <1284,3,1> because sectors number start from 0. please clear my doubt
0
0
In Laxmi's solution when it is known that 194 more sectors are required from <1284,0,0> onwards, surface numbers 0,1 &2 (3 surfaces will cover 3*64= 192sectors).,know 2 more required,now  <1284,3,0>will be 193rd and <1284,3,1>will be last .please correct if  it's wrong.
4
4
address of last sector is why not 1229416+(85594-1), since sector numbers start with 0??

plzz someone resolve this doubt.
7
7
Yes,you are right.. Sector numbers are 0-63.. Hence last sector will be 1.. Thanks for pointing this out..
0
0
thank god.. I was so much into worry and thinking over this question again and again. So plz correct the answer and edit it. Thanx again for giving it a thought.
0
0
How many sectors per cylinder for this question?

64 or 16*64.If later one,then why?
1
1
edited by

In these types of questions we have to use "CHS to LBA mapping".
Given address is in CHS format then we first convert it into LBA, then after adding file size we have to convert back into CHS.


https://en.wikipedia.org/wiki/Cylinder-head-sector#CHS_to_LBA_mapping

https://en.wikipedia.org/wiki/Logical_block_addressing#CHS_conversion

21
21

Thanks Sachin for sharing this useful link. 

Now come to the calculation. For example as per above calculation <0,0,40> will become LBA 40. means LBA also starts from 0. So, when reversing LBA to CHS no need to subtract 1 at the last step of sector address calculation.That would result LBA 40 to become <0,0,39> which is incorrect. So, correct CHS of this answer would be <1284,3,2>

refer - https://en.wikipedia.org/wiki/Logical_block_addressing#CHS_conversion 

2
2

last sector to store file = 1229416+85594=1315010

I think there we need to subtract 1

last sector to store file = 1229416+85594-1=1315009

Even if you do reverse map,the final answer will give:- 

(1284 * 16 * 64) + ( 3 * 64) + 1 = 1315009

2
2
@rahul. Can you tell me what is starting LBA here? is it 1 or 0?

i.e. CHS <0,0,0> will be LBA 0 or LBA 1?

I've some doubt regarding this. Can you please help me to understand.
0
0
Thanks best explained
0
0

@All

Please explain the following line,

(1200 '* 16 * 64) + ( 9 * 64) + 40 = 1229416

0
0
Why only sector no. Of last sector address is subtracted by 1? Even cylinder no. & Surface no. are also starting from 0 right?
1
1
Its (0,0,0)
0
0
here each cyllinder contains 16 sectors  and each surface contain 16384 cyllinder then how you write this line---

 

(1200×16×64)+(9×64)+40=1229416
0
0
Is there any book which contains similar question like this one, and explains the topic
0
0
Great explanation!
0
0
It should be-

Last sector to store file =1229416+85594-1=1315009
3
3

@sushmita why we are not adding 41 sectors instead of 40 sectors in case of first calculating the total address?

Because sectors numbers are started from 0,so 0-40 total 41 sectors present.

 

0
0
I think, last sector num is 1315009
0
0
How you get 40 ,why not 40-1 =39  for sector number when converting chs to lba
0
0

My solution : 

Size of each cylinder is =  1 cylinder * 16 surfaces * 64 sectors *  512 bytes 

                                     =  524288 bytes

Size of given file = 42797 K bytes

                           = 42797 * 1024  bytes    [1Kbytes = 1024 bytes ]

                           = 43824128 bytes

No. of cylinders required for given file = (size of given file / size of each cylinder)

                                                            = 43824128 / 524288

                                                            = 83.5878907 cylinders

                                                            = 83 cylinders + (greater than 8 surfaces)  [0.5 cylinder is 8 surfaces]

So ,

<1200,9,40> +  83 cylinders + (greater than 8 surfaces)  =  <1284 , greater than 1st surface no. , something>

             

So last sector of the file is in 1284th  cylinder.

Note : Don't take 1Kbytes = 10^3 bytes here 

2
2
1315010 mod (16×64)=194

similarly, 194 mod 64=2
0
0
edited by

In the last line 

$\therefore \langle 1284,3,1\rangle$

it should be $\langle 1284,3,2\rangle$ because 194mod64 = 2 and this 2 is sector number itself and not the number of sectors. So it actually means 2th sector.

$\langle 1284,3,1\rangle = (1284 \times \mathbf{16 \times 64}) + ( 3 \times \mathbf{64}) + 1 = 1315009$

$\langle 1284,3,2\rangle = (1284 \times \mathbf{16 \times 64}) + ( 3 \times \mathbf{64}) + 2 = 1315010$

And the last sector to store file is 1315010.

1
1

@vaibhavkedia968

sector address is nothing but the (no of sectors before that sector + 1) so the last address will be   ⟨1284,3,1⟩  this only  it is correct!

0
0

@Laxmi

I think the address will be 1284,3,2 since we didn't altered the address while converting it from the formatted address we should not overthink while converting it back.

0
0

@Pranavpurkar

Then before converting address to sector number also we should have added 1 to the sector number to get the actual sector number since address starts from 0 then 40th sector is the 41th sector anyhow it would have ended in 2nd sector. They should have asked the sector number then many would have lost their marks 😂

0
0
48 votes
48 votes
$42797\; KB = 42797 \times 1024$ bytes require $42797 \times 1024 / 512$ sectors $=  85594$ sectors.

$\langle 1200, 9, 40 \rangle$ is the starting address. So, we can have $24$ sectors in this recording surface. Remaining $85570$ sectors.

$85570$ sectors require $\lceil \frac{85570}{64}\rceil= 1338$ recording surfaces. We start with recording surface $9,$ so we can have $7$ more in the given cylinder. So, we have $1338 - 7 = 1331$ recording surfaces left.

In a cylinder, we have $16$ recording surfaces. So, $1331$ recording surfaces require  $\lceil \frac{1331}{16}\rceil = 84$ different cylinders.

The first cylinder (after the current one) starts at $1201.$ So, the last one should be $1284.$

$\langle 1284, 3, 1 \rangle$ will be the end address. $(1331 - 16 \times 83 +1  - 1 = 3$ $(3$ surfaces full and $1$ partial and $-1$ since address starts from $0),$ and $ 85570 - 1337 \times 64 -1 = 1)$
by

4 Comments

Perfect answer. :)

Cleared the doubt as well as concept
0
0

Arjun Sir,  I think "each cylinder contains 64 sectors (0-63)" this statement given in the question is wrong, it should have been like "each surface contains 64 sectors (0-63)". Please clear my doubt.

7
7

@Sourav Basu 16384 cylinders mean due to cylinders there will be tracks made to each surface because a cylinder separates 2 tracks. Kindly see the relation between cylinders and tracks. So logically, there are 16384 tracks per surface and each track having 64 sectors.

0
0
25 votes
25 votes
  • 16 Surfaces(0-15)
  • 16384 cylinders (0-16383)
  • Each cylinder has 64 sectors (0-63)
  • Sector Capacity=512 Byte
  • File Size =42797KB
  • Number of sectors required by file = $\frac{42797*1024(Bytes)}{512}= 85594$
  • #Sectors per cylinder = 16*64 = 1024
  • Starting disk location of file = <1200,9,40>
  • Remaining sectors to be filled till next cylinder 1201 will be
    (63-40+1)(Head number 9(means surface 10th) is completely filled + (15-10+1)*64 = 408
  • Remaining sectors to be allocated to file  = 85594-408=85186
  • These 85186 sectors will take  = $\left \lceil \frac{85186}{1024} \right \rceil = 84$ cylinders
  • Means inclusive of 1201, we need to add 83 more cylinders, so answer= 1201+83=1284 Cylinder number

4 Comments

@tusharp-After filling 10th surface completely(s=9), remaining surface numbers are 10,11,12,13,14,15-> 6 of them with 64 sector each.

So, sectors remaining to fill cylinder 1200->24+6*64 and you did 24+7*64
1
1
Use CHS to LBA Mapping formula and you'll get answer fast
1
1

@Ayush Upadhyaya

Can you please tell the difference between below 2 lines .

  • Each cylinder has 64 sectors (0-63)
  • #Sectors per cylinder = 16*64 = 1024

 

3
3
9 votes
9 votes

Cylinder no 1284

1 comment

everything is fine except "1200 cylinder no instead of 1201 "

bcz we are currently on 1200 cylinder & 9th surface .

 9th surface already filled with 40 sectors remaining 24 left
0
0
Answer:

Related questions