CN1288562C - Method for detecting disk replacement for floppy disk drive - Google Patents

Method for detecting disk replacement for floppy disk drive Download PDF

Info

Publication number
CN1288562C
CN1288562C CN 03127521 CN03127521A CN1288562C CN 1288562 C CN1288562 C CN 1288562C CN 03127521 CN03127521 CN 03127521 CN 03127521 A CN03127521 A CN 03127521A CN 1288562 C CN1288562 C CN 1288562C
Authority
CN
China
Prior art keywords
disc
floppy disk
thread
detection
foreground
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN 03127521
Other languages
Chinese (zh)
Other versions
CN1581093A (en
Inventor
刘文涵
宋建福
焦学莲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inventec Corp
Original Assignee
Inventec Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inventec Corp filed Critical Inventec Corp
Priority to CN 03127521 priority Critical patent/CN1288562C/en
Publication of CN1581093A publication Critical patent/CN1581093A/en
Application granted granted Critical
Publication of CN1288562C publication Critical patent/CN1288562C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Signal Processing For Digital Recording And Reproducing (AREA)

Abstract

The present invention relates to a method for detecting the replacement of disks of a floppy disk drive, which realizes the irrelevancy of test and time by detecting the replacement in a multithread method. The present invention comprises the following steps: firstly, starting foreground prompting program and background detection program; afterwards, prompting users replacing a disk by the foreground program and detecting state code returned from the floppy disk drive by the background program; in the next place, determining the condition of replacement according to the state code and stopping foreground prompting program; finally, outputting detection results according to the condition of replacement.

Description

Detect the method for floppy disk disc change
Technical field
The present invention relates to a kind of method that detects floppy disk, particularly a kind of method that detects the floppy disk disc change.
Background technology
On computer line, need carry out integrated testability to each parts of computing machine, floppy disk (Floppy Disk Driver) with diskette sheet as data medium, be the important interfacing equipment of computing machine, it is tested is pith indispensable in the computing machine integrated testability.Floppy disk is made up of disc condition monitoring system, disc drive mechanism, magnetic head positioning system and data read-write system four parts; condition detecting system wherein comprises that more the detection of " 00 " magnetic track, write-protect detection, index signal detect and disc is replaced four pick-up units of detection; to just having comprised the disc change test in the test of floppy disk, determine by this test whether the work of disc change pick-up unit is normal in the floppy disk.
For example, for (SuSE) Linux OS, in the prior art, testing for floppy disk is the IOCTL function transmission FDGETDRVSTAT order (obtaining the order of floppy disk state) that is provided by utilizing under the (SuSE) Linux OS to the floppy disk of opening, and whether is changed the information of disc from the return results of function.And in the applied environment of reality, can find, though can judge the replacing of floppy disk by this method to disc, but exist some unconquerable shortcomings: after the order of floppy disk state is obtained in transmission for the first time, the floppy disk pilot lamp is opened, if this moment, we changed disc immediately, the result that function returns has changed disc; If but postpone a period of time, and after extinguishing, the pilot lamp for the treatment of floppy disk removes to change disc again, and the result that function returned just becomes and does not change disc, does not obviously meet with actual situation.So, we just must be in the regular hour (promptly before the floppy disk pilot lamp extinguishes) finish the operation of changing disc and just can obtain correct testing result.Yet, on computer line, computing machine is carried out in the process of integrated testability, the tester can not in time finish the operation of changing disc in official hour, when occurring changing the disc mistake, just its reason of makeing mistakes of judgement that can't be correct is that the tester fails in time to change disc actually, still the disc change pick-up unit of floppy disk has fault, like this will be for test bring error, thus reduced the efficient of test.
At this moment, be not subjected to the disc change method of testing of time restriction to solve the problems referred to above in the time of just need a kind ofly changing disc.
Summary of the invention
In view of this, the present invention addresses the above problem a kind of method that detects the floppy disk disc change that proposed, when its purpose is to change the detection of disc on computer line, can reach the independence of test and time, thereby reduce test error.
The present invention proposes a kind of method that detects the floppy disk disc change, this method comprises the steps: at first to start foreground (foreground) prompting thread under (SuSE) Linux OS and backstage (background) detects thread; This foreground thread prompting user changes disc then; This background thread detects the status code that floppy disk returns; Determine the replacing situation of disc according to this status code: when when the status code of returning is 0, representing there is disc in the floppy disk and is in non-write-protect state, illustrate that disc is not replaced, when the state that returns is represented to exist in the floppy disk disc and is in the write-protect state during for EROFS, illustrate that disc is not replaced, represent not have disc in the floppy disk during when the state that returns, illustrate that disc is replaced for Enxio; Finish this prompting thread on the foreground; And export testing result according to the replacing situation of described definite disc at last.
Compare with classic method, method provided by the present invention utilizes the method for multithreading under the (SuSE) Linux OS to detect the floppy disk replacing, has realized test and the independence of time.It has been abandoned to driver and has sent the method for checking status command, but constantly detects the situation that whether has disk in the driver by detecting thread.Use the advantage of multithreading to be: the real-time response ability of improvement program, more effective use multiprocessor, improvement program structure and reduce use to system resource, thus reduced the probability of makeing mistakes, improved the efficient of test.
Relevant detailed content of the present invention and method, existing conjunction with figs. is described as follows.
Description of drawings
Fig. 1 is the overview flow chart of the method for detection floppy disk disc change of the present invention;
Fig. 2 is a process flow diagram of determining subsequent operation according to this status code proposed by the invention;
Fig. 3 is a process flow diagram of determining the replacing situation of disc according to this status code proposed by the invention; And
Fig. 4 is the process flow diagram according to this replacing situation output testing result proposed by the invention.
Wherein, description of reference numerals is as follows:
110 start foreground prompting thread and backstage detection thread
120 these foreground thread prompting users change disc
130 these background thread detect the status code that floppy disk returns
140 determine the replacing situation of disc according to this status code
150 finish this prompting thread on the foreground
160 according to this replacing situation output testing result
210 when the status code of returning is Enxio, finishes this detection thread, and the resource of release busy
220 when the status code of returning be 0 or during EROFS, continue to detect the return state sign indicating number of floppy disk
310 represent to have disc in the floppy disk and be in non-write-protect state when the status code of returning is 0, illustrate that disc is not replaced
320 represent to exist in the floppy disk disc and are in the write-protect state during for EROFS when the status code of returning, and illustrate that disc is not replaced
330 represent not have disc in the floppy disk during for Enxio when the status code of returning, and illustrate that disc is replaced
410 when disc is replaced, and is successful to the user report disc change by the foreground thread
420 when disc is not replaced, and fails to the user report disc change by the foreground thread
Embodiment
The present invention is described in detail below in conjunction with accompanying drawing:
See also Fig. 1, this figure is the overview flow chart of the method for detection floppy disk disc change of the present invention, is described as follows:
At first start foreground prompting thread and backstage and detect thread (step 110); This foreground thread prompting user changes disc (step 120) then; This background thread detects the status code (step 130) that floppy disk returns; Determine the replacing situation (step 140) of disc according to this status code; Finish this prompting thread (step 150) on the foreground; At last according to this replacing situation output testing result (step 160).
Characteristics of the present invention are to have used thread in testing process, its advantage is as follows:
(1) independence of test and time.After the test beginning, foreground prompting thread prompting user changes floppy disk, and no matter when the user changes operation, can both obtain correct testing result;
(2) improved the reliability of testing.Owing to overcome the error that time restriction is brought, made test result more accurate; And
(3) flow process is simple and direct, realizes simpler.Detecting the disk replacing is to carry out on the backstage, can not disturb normally carrying out of other test.
The mechanism that realizes multithreading under linux is exactly the task sharing internal memory, thereby the multithreading processing can reduce system overhead to a great extent.Multithreading is followed POSIX thread interface, is called pthread.The present invention utilizes phtread_create () function to start thread, and four parameters are arranged in this function:
(1) Thread Id (thread ID) sign, it is the pointer of receiving thread unique identifier, each thread in process is all identified by a Thread Id (thread ID), its data type is pthread_t (usually being unsigned int), can be called by other application program in case of necessity;
(2) thread property parameters can support a plurality of scheduling option attributes to set.Being provided with of property parameters can be called the phtread_attr_init function.Its data type is pthread_attr_t, and whether attributes object mainly comprises whether binding, separates, stack address, storehouse size and priority.Be set to Null among the present invention, expression utilizes default thread attribute.Default attribute be unbundling, non-separation, 1M storehouse, with other priority of the same level of parent;
(3) title of the function that will carry out of thread, this parameter is pointed to the function that thread will be carried out, and the performed function of thread is exactly to detect the function that whether has disc in the floppy disk in the present invention, its data type is void*, has called the open function that system provided in this detection function; And
(4) pass to function parameters, the call by value parameter of the function that will carry out for thread, its data type is void*, if there is not parameter value, can be set to Null.This parameter is set to Null among the present invention.
After the thread startup was detected on the backstage, when foreground prompting thread prompting user changed disc, the backstage was detected thread whether disc in the cycle detection floppy disk is changed.Whether, be by open floppy disk, detect that status code that floppy disk returns judges if detecting disc and being present in the floppy disk.Its call function is open (), and this function has two parameters.One is which kind of equipment what to be opened be, as Winchester disk drive, floppy disk, CD-ROM drive etc.Among the present invention for opening floppy device; Another one is the mode of opening, and usual way has two kinds: O_RDONLY read-only mode and O_RDWR read-write mode, the present invention opens floppy disk with the O_RDWR read-write mode.
Further the present invention will be described below.
See also Fig. 2 and illustrate, this figure proposed by the inventionly determines to be described as follows the process flow diagram of subsequent operation according to this status code:
When the status code of returning is Enxio, finish this detection thread, and the resource (step 210) of release busy; When the status code of returning is 0 or during EROFS, continue to detect the return state sign indicating number (step 220) of floppy disk, enter step 140 at last.
The method that finishes thread can call function pthread_attr_destroy (; Attr), wherein attr is the property parameters of thread.
See also Fig. 3, this figure proposed by the invention determines to be described as follows the process flow diagram of the replacing situation of disc according to this status code:
When the status code of returning is 0, represent to have disc in the floppy disk and be in non-write-protect state, illustrate that disc is not replaced (step 310); Represent to exist in the floppy disk disc and be in the write-protect state during when the status code of returning, illustrate that disc is not replaced (step 320) for EROFS; Represent not have disc in the floppy disk during when the status code of returning, illustrate that disc has been replaced (step 330), enters step 150 at last for Enxio.
Call function is opened floppy disk with open () with the O_RDWR read-write mode, detects the status code that floppy disk returns.If there is disc in the driver, and be in non-write-protect state, then its open mode sign indicating number that returns should be 0; If there is disk in the driver, but be in the write-protect state, then its open mode sign indicating number that returns should be EROFS, and the file system on the disc that expression is opened is read-only, does not have to write authority; If there is not disk in the driver, then its open mode sign indicating number that returns should be Enxio, and recordable medium are not found in expression.
Finishing this prompting thread on the foreground is to click in the dialog box of confirming by the user to finish to finish, and after the user clicks end, if disc is replaced, detects the resource of thread with automatic end and release busy according to step 210 backstage; If disc is not replaced, then finishes this backstage at this moment and detect thread, the resource of release busy.
See also Fig. 4 and illustrate, this figure is the process flow diagram according to this replacing situation output testing result proposed by the invention, is described as follows:
When disc is replaced, by the foreground thread to user report disc change success (step 410); When disc is not replaced, by the foreground thread to user report disc change failure (step 420).
With an example flow process of the present invention is described below.
At first carry out trace routine and begin to detect, utilize pthread_create () function to start thread, comprise foreground prompting thread and backstage detection thread, wherein this foreground prompting thread is used for information, confirms that user's selection and user carries out alternately; The situation that thread is used for continuous cycle detection disc change is detected on the backstage.
This foreground prompting thread is changed disk with the form prompting user of dialog box, meanwhile, background thread starts, and opens floppy disk by call function open () with the O_RDWR read-write mode, and the status code that the detection floppy disk returns detects the driver disc state.
Changed disc if detect the user, the backstage is detected thread and will be detected disc change and stop this thread, and user's end dialog frame is waited for then, and trace routine detects successfully to user report.
If the user does not carry out the disc change operation, background thread will constantly be carried out the disc state-detection and be waited for until user's end dialog frame.Wait for that when user's end dialog frame the backstage is detected thread and will be terminated.Do not change owing to detect disk, trace routine is changed failure to the user report disk.
So far, floppy disk disc change testing process is all over.
The present invention is simultaneously applicable to detecting in the floppy disk whether have disc.
The above only is the present invention's preferred embodiment wherein, is not to be used for limiting practical range of the present invention; All equalizations of doing according to description of the present invention change and modify, and are all claim of the present invention and contain.

Claims (7)

1, a kind of method that detects the floppy disk disc change is characterized in that, this method comprises the steps:
Under (SuSE) Linux OS, start foreground prompting thread and backstage and detect thread;
This foreground thread prompting user changes disc;
This background thread detects the status code that floppy disk returns;
Determine the replacing situation of disc according to this status code: when the status code of returning is 0, represent to exist in the floppy disk disc and be in non-write-protect state, illustrate that disc is not replaced; Represent to exist in the floppy disk disc and be in the write-protect state during when the state that returns, illustrate that disc is not replaced for EROFS; Represent not have disc in the floppy disk during when the state that returns, illustrate that disc is replaced for Enxio;
Finish this prompting thread on the foreground; And
Replacing situation output testing result according to described definite disc.
2, the method for detection floppy disk disc change as claimed in claim 1 is characterized in that, it is to detect the status code of being returned when opening floppy disk with read-write mode that background thread detects status code that floppy disk returns.
3, the method for detection floppy disk disc change as claimed in claim 1, it is characterized in that, more comprise when the state that returns is Enxio after the step of the status code that this background thread detection floppy disk returns, finish this detection thread, and the step of the resource of release busy.
4, the method for detection floppy disk disc change as claimed in claim 1, it is characterized in that, this background thread detect more comprise after the step of the status code that floppy disk returns when the state that returns be 0 or during EROFS, continue the step of the return state sign indicating number of detection floppy disk.
5, the method for detection floppy disk disc change as claimed in claim 1 is characterized in that, finishes on the foreground also to comprise when disc is not replaced after the step of this prompting thread, finish this backstage and detect thread, and the step of the resource of release busy.
6, the method for detection floppy disk disc change as claimed in claim 1 is characterized in that, exports testing result for when disc is replaced according to the replacing situation of described definite disc, and is successful to the user report disc change by the foreground thread.
7, the method for detection floppy disk disc change as claimed in claim 1 is characterized in that, exports testing result for when disc is not replaced according to the replacing situation of described definite disc, fails to the user report disc change by the foreground thread.
CN 03127521 2003-08-06 2003-08-06 Method for detecting disk replacement for floppy disk drive Expired - Fee Related CN1288562C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 03127521 CN1288562C (en) 2003-08-06 2003-08-06 Method for detecting disk replacement for floppy disk drive

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 03127521 CN1288562C (en) 2003-08-06 2003-08-06 Method for detecting disk replacement for floppy disk drive

Publications (2)

Publication Number Publication Date
CN1581093A CN1581093A (en) 2005-02-16
CN1288562C true CN1288562C (en) 2006-12-06

Family

ID=34578828

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 03127521 Expired - Fee Related CN1288562C (en) 2003-08-06 2003-08-06 Method for detecting disk replacement for floppy disk drive

Country Status (1)

Country Link
CN (1) CN1288562C (en)

Also Published As

Publication number Publication date
CN1581093A (en) 2005-02-16

Similar Documents

Publication Publication Date Title
US7953772B2 (en) Method and system for inspecting memory leaks and analyzing contents of garbage collection files
CN1008778B (en) The method and apparatus that is used for fault recovery in the computing system
US8229979B2 (en) Method and system for inspecting memory leaks
US6742148B1 (en) System and method for testing memory while an operating system is active
JP4436036B2 (en) Information processing apparatus, trace processing method, program, and recording medium
CN1313930C (en) Fault tracing in systems with virtualization layers
CN105223889A (en) A kind of method being applicable to the automatic monitoring PMC RAID card daily record of producing line
US20080276129A1 (en) Software tracing
US8793289B2 (en) Method and system for detecting memory leaks and copying garbage collection files
CN1920793A (en) Device and method for implementing test scenarios replay in different voice environment
CN1967499A (en) Journal output system and output method
CN107273257A (en) A kind of automatic method for carrying out the out of order inspection of hard disk under linux system
CN113110960A (en) Automatic tuning test method and system based on hard disk performance
CN115328796A (en) Software vulnerability auxiliary positioning method and system for ARM architecture
US6513133B1 (en) Uniformly distributed induction of exceptions for testing computer software
CN101051220A (en) Method for centralization of process sequence checking
CN101034402A (en) Method and apparatus for handling a user-defined event that is generated during test of a device
CN1288562C (en) Method for detecting disk replacement for floppy disk drive
US6229743B1 (en) Method of a reassign block processing time determination test for storage device
CN114647588A (en) Interface test method and device
CN1959646A (en) System and method for testing correctness of position of installing hard disk
CN113360389A (en) Performance test method, device, equipment and storage medium
CN109857715B (en) Log recording method and system for strengthening error checking support
CN1297895C (en) Integral control and management system and method for computer production line
JPH11259374A (en) Device and method for testing memory and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20061206

Termination date: 20100806