Solved

locking hard drive while reading sectors

Posted on 2002-06-08
13
220 Views
Last Modified: 2012-05-04
i am using int 21h function 7305h extended absolute disk read write
to access my 20GB hard drive.i am performing only read operation.
should i need to use some form of lock which i keep hearing about during i read the sectors.i am using 16 bit computing.

thank you.
0
Comment
Question by:vinayak_j
  • 4
  • 4
  • 2
  • +3
13 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 75 total points
ID: 7064535
If this is for DOS, then no.   DOS is a singletheaded OS and there is no chance of another thread accessing the drive.

If this is for windows....

Well what is it you are writting?  Is this a driver?
0
 
LVL 32

Expert Comment

by:jhance
ID: 7064621
If you are ONLY reading then there should be no need to lock anything.  If you were doing a read/update/write operation then you must lock to be sure that nothing write new data to the sector during the update interval or you will overwrite whatever data was written since you last read it.
0
 
LVL 22

Expert Comment

by:nietod
ID: 7064641
Well, you could potentially read data that was being written to by anoher thread and thus get data that was 1/2 the old value and 1/2 the new and thus--in a sense corrupted.

I'm sure of the context of this, so I'm not sure if that a possiblity in this case or not.
0
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
LVL 32

Expert Comment

by:jhance
ID: 7064748
Not at the sector level.  Since the SMALLEST unit of data that can be written to or read from a hard drive is a sector, and typical hard drives have ONLY one R/W head and cannot do more than one thing at a time, you cannot read a sector that has been 1/2 written.  A sector write operation is indivisible from a system level point of view.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7064765
hi vinayak_j,
Are you getting an error when you use int 21h function 7305h?

If so, what is the error code?
-- Dan
0
 

Author Comment

by:vinayak_j
ID: 7090036
this is for DanRollins i do not get any error.
i am now able to successfully access the drive.sorry for being late.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7091123
If you have solved the prolem youself, please delete this question.  To do that, please post to Community Support.  Thanks.

-- Dan
0
 
LVL 32

Expert Comment

by:jhance
ID: 7092267
I don't see this as a candidate for deletion.  The question is a legitimate one and has been addressed by experts.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7093138
>>I don't see this as a candidate for deletion
jhance,
Which expert comment could possibly have provided the answer?  There is nothing here but requests for feedback and broad generalities and unrelated chaffe about reading 1/2 sector.

-- Dan
0
 
LVL 32

Expert Comment

by:jhance
ID: 7093153
I stand by my position.  There is no possibility for reading/writing 1/2 a sector.  

From a disk subsystem point of view a sector is indivisible. (i.e. it's an ATOM)

This user asked: "should i need to use some form of lock"

Answer, NO!

I say give the points to nietod.  While he was a bit incomplete (due to lack of information from user) he is, nonetheless, correct.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7093257
Sorry jhance,
On a re-read of the Q, I agree.  neitod answered the posted question fully and correctly.  He deserves credit.
-- Dan
0
 
LVL 11

Expert Comment

by:griessh
ID: 7261749
Dear vinayak_j

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "nietod"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7332912
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question