Top Post

6/recent/ticker-posts

CS609 Assignment 03 Solution By VUBWN | CS609 Assignment 03 Solution 100% Correct Solution

 CS609 Assignment 03 Solution By VUBWN | CS609 Assignment 03 Solution 100% Correct Solution


CS609 Assignment 03 Solution By VUBWN | CS609 Assignment 03 Solution 100% Correct Solution




Task 2:

Read the drive parameters of the first removable disk of the system. (The drive parameters will be returned in the buffer that is passed as a parameter). After reading, write the contents of the buffer in a file.

Answer:

Suppose We have Image into the Buffer So the Code for detecting image is Following

void writeImageFromBuffer ( const char* filename , const char* buffer , unsigned long length )

{

    const int REGULARPACKAGE_SIZE = 1024;

    FILE *image;                                  /* Pointer to file */

    unsigned long bytesWritten;                   /* Bytes written so far in the buffer */

    int bytesToWrite;                             /* Bytes to write to file */                            

    char *tmpBuffer;                              /* Temporary buffer */

   

    bytesWritten = 0;

 

    image = fopen ( filename , "wb" );    

 

    // allocate tmpBuffer

    tmpBuffer = (char *) malloc ( REGULARPACKAGE_SIZE );

   

    while ( bytesWritten < length )

    {

        if ( length - bytesWritten >= REGULARPACKAGE_SIZE )  /* not last frame */

        {

            bytesToWrite = REGULARPACKAGE_SIZE;

        }

        else                                                 /* last frame */

        {

            bytesToWrite = length - bytesWritten;            

            // reallocate tmpBuffer to its adecuate size

            tmpBuffer = (char *) realloc ( tmpBuffer , bytesToWrite );

        }

        // copy original buffer <bytesToWrite> elements to tmpBuffer

        tmpBuffer = &buffer[bytesWritten];

        // write tmpBuffer to file

        fwrite ( tmpBuffer , 1 , bytesToWrite , image );

        // just upgrade the var

        bytesWritten += bytesToWrite;

    }

   

    fclose ( image );  

}

 

 

Task 3:

Format Track number 1 and set the bad-sector Flags (if bad-sectors are present) of first removable disk of your system. The remaining parameters should be as follows:

1.      Head number = 0

2.      Sector number = 1

3.      Total number of sectors (nSect)

 

Solution:

There will be No Bad Sectors in to the removable disk as when you start to see bad sectors then it is time to replace your drive.

The capacity of the disk (in GB) * 1024 * 1024 * 2.

 For example, a 1TB Disk will have 1024 * 1024 * 1024 * 2 sectors = 2147483648 sectors.

 A disk typically has each sector of size 512 bytes.

Highest biosdisk() capacity

         Hence the highest capacity of disk can be accessed using bios functions is

         63x16x1024x512= 504 MB approx.

If we use 1Tb then each sector will be 512 Bytes, So Total Number of Sectors will be 2147483648.


 

Download PDF Solution File

Post a Comment

0 Comments