Video-recording and replaying apparatus, I/O scheduling method, and program

A video-recording and replaying apparatus includes a block device for use as a recording medium for video-recording and a control part, when a plurality of tasks each representing a process in regard to video-recording and replaying on the block device are executed, performing I/O scheduling on the block device by using time slices each predetermined for each of the tasks so that a total amount of I/O data for each of the tasks in each round-robin cycle for the block device is approximately equal.

CROSS-REFERENCE TO RELATED APPLICATION

The present application claims priority from Japanese Patent Application No. JP 2010-226674 filed in the Japanese Patent Office on Oct. 6, 2010, the entire content of which is incorporated herein by reference.

BACKGROUND

The present disclosure relates to a video-recording and replaying apparatus, I/O scheduling method, and program capable of performing I/O scheduling on a block device in a multitask environment.

In recent years, general video-recording and replaying apparatuses can perform simultaneous video-recording of a plurality of channels and video-recording of a program while replaying a video-recorded program. As a storage for these video-recording and replaying apparatuses, a block device is used, such as a Blu-ray drive or a hard disk drive. The block device is a storage in which data write and read are performed by a predetermined unit (a block unit). Inputs and outputs of data to and from the block device are performed through a file system.

For simultaneous video-recording of a plurality of channels and simultaneous video-recording and replaying for the block device, it is important to impartially allocate I/O (input/output) resources for the block device to each process. I/O scheduling is a technology of impartially allocating I/O resources for the block device to a plurality of tasks.

For example, a CFQ (completely fair queuing) scheduler is an I/O scheduler currently incorporated in a Linux kernel as a standard (refer to Japanese Unexamined Patent Application Publication No. 2010-113524 (paragraphs [005]-[0058])). In the CFQ scheduler, an I/O request is registered in a request queue corresponding to a degree of priority. In each request queue, a time slice determined according to the degree of priority of the I/O request is set. Normally, an I/O request from a task with a relatively high degree of demand for real-time properties is provided with a high degree of priority, and an I/O request from a task with a relatively low degree of demand for real-time properties is provided with a low degree of priority.

The CFQ scheduler merges I/O requests to adjacent sectors into a single data structure called an I/O request for each same type (read request or write request), and registers the I/O request in a request queue. The CFQ scheduler selects one request queue not being blank from among a plurality of request queues with a round-robin scheme, for example, selecting the I/O requests one by one from the selected request queue within the time slice and passing the I/O requests to a device driver. After a lapse of the time slice, the CFQ scheduler selects a request queue with the same or next higher degree of priority, and selects an I/O request from that request queue and passes the I/O request to the device driver. With this, the I/O requests are executed by the device driver.

SUMMARY

As described above, in the CFQ scheduler, an I/O request from a task with a relatively high degree of demand for real-time properties is provided with a high degree of priority, and an I/O request from a task with a relatively low degree of demand for real-time properties is provided with a low degree of priority. More specifically, the frequency of access to the block device (the frequency of occurrence of an I/O request) or the like is used as an index for determining the degree of priority.

However, at fast-forward replay, data is typically read from the block device at a high rate compared with that at normal replay. For this reason, the number of I/O requests per unit time is large. Therefore, when the degree of priority is determined in consideration of the frequency of access to the block device according to a typical I/O scheduling technique, an I/O request for fast-forward replay is allocated with a high degree of priority, and is also allocated with a long time slice accordingly. However, when a long time slice is allocated to a specific task, a large number of I/O resources for the block device are used to process that task. For this reason, when another real-time task, such as video-recording or normal replay, is to be performed simultaneously with fast-forward replay, it may be difficult to allocate I/O resources sufficient for performing this other real-time task. In particular, at video-recording or replaying of a program, read or write is continuously performed onto the block device for a relatively long time. Therefore, continuous shortages of I/O resources may cause an actual damage, such as buffer underrun.

It is desirable to provide a video-recording and replaying apparatus, I/O scheduling method, and program capable of reducing nonuniformity of the amount of I/O data for a block device among tasks and excellently performing multitasking in regard to video-recording and replaying.

A video-recording and replaying apparatus according to an embodiment of the present disclosure includes a block device for use as a recording medium for video-recording and a control part, when a plurality of tasks each representing a process in regard to video-recording and replaying on the block device are executed, performing I/O scheduling on the block device by using time slices each predetermined for each of the tasks so that a total amount of I/O data for each of the tasks in each round-robin cycle for the block device is approximately equal.

In an embodiment of the present disclosure, a time slice for each task is uniquely set in advance. The time slice fixed for each task is set not by following a typical I/O scheduling technique of increasing the time slice for a real-time task with a higher degree of frequency of access to the block device, but is set to have a value so that a total amount of I/O data for each task in each round-robin cycle for the block device is approximately equal. With this, when I/O resources for the block device are shared among tasks, nonuniformity of the amount of I/O data among tasks can be reduced. This is particularly useful when fast-forward replay and video-recording of a broadcast program are simultaneously performed in a video-recording and replaying apparatus, and the reason for this is as follows. At fast-forward replay, I/O processing is performed on the block device at a high rate compared with that at video-recording. According to typical I/O scheduling, a large number of I/O resources are used by this fast-forward replay task, and I/O resources to be allocated to a task for video-recording a broadcast program tend to run short. If I/O resources to be allocated for transmission to the block device from a buffer area where program data received in video-recording of a broadcast program is temporarily stored are decreased, a video-recording error occurs due to buffer overflow. According to the embodiment of the present disclosure, the occurrence of such a video-recording error can be prevented.

When a request queue of a task being selected is blank, the control part performs task switching without waiting for a lapse of the time slice. With this, use efficiency of I/O resources can be improved. Also from this point of view, multitasking in regard to video-recording and replaying can be excellently performed.

The control part repeatedly performs a process of setting a time obtained by subtracting an excess from the time slice at the end of execution of an I/O request from a default time slice as a time slice in a next round-robin cycle and resetting the time slice to the default time slice in a cycle subsequent to the next cycle. This can prevent accumulation of delay times in timings of starting a process of a task subsequent to a task for I/O processing on the block device at a high rate, such as fast-forward replay, and can more mitigate nonuniformity of the amount of I/O data among tasks.

In an I/O scheduling method of a video-recording and replaying apparatus according to another embodiment of the present disclosure, when a plurality of tasks each representing a process in regard to video-recording and replaying on a block device for use as a recording medium for video-recording are executed, I/O scheduling is performed on the block device by using time slices each predetermined for each of the tasks so that a total amount of I/O data for each of the tasks in each round-robin cycle for the block device is approximately equal.

A program according to still another embodiment of the present disclosure causes a computer to operate as a control part performing I/O scheduling on a block device for use as a recording medium for video-recording by using time slices each predetermined for each of a plurality of tasks each representing a process in regard to video-recording and replaying on the block device so that a total amount of I/O data for each of the tasks in each round-robin cycle for the block device is approximately equal.

According to the embodiments of the present disclosure, nonuniformity of the amount of I/O data for a block device among tasks can be reduced, and multitasking in regard to video-recording and replaying can be excellently performed.

DETAILED DESCRIPTION OF EMBODIMENTS

With reference to the drawings, embodiments of the present disclosure are described below.

An embodiment relates to a video-recording and replaying apparatus capable of video-recording program data, such as video and audio, obtained from outside in a block device, such as a Blu-ray disk or a hard disk drive, and replaying the video-recorded program data. Also, another embodiment relates to a video-recording and replaying apparatus capable of performing a plurality of processes with I/O (input and output) to or from a block device virtually at the same time, the processes including simultaneous video-recording of a plurality of channels and simultaneous video-recording and replaying.

Embodiment

Hardware Structure of the Video-Recording and Replaying Apparatus

FIG. 1is a block diagram of the structure of a video-recording and replaying apparatus100according to an embodiment of the present disclosure.

As depicted inFIG. 1, this video-recording and replaying apparatus100includes, for example, a CPU11(a control part), a main memory12, a program storage part13, a program receiving part14, a block device15, program replaying parts16, and a bus17.

The CPU (central processing unit)11totally controls each part of the video-recording and replaying apparatus100. The CPU11performs various processes in regard to video-recording and replaying of a program by using various programs and data, such as an OS and an application program, stored in the program storage part13.

The main memory12is a memory for use as a working space of the CPU11.

The program storage part13is a storage part having stored therein various programs to be executed by the CPU11and data for executing these programs.

The program receiving part14is, for example, a digital tuner, such as a terrestrial digital tuner, a BS digital tuner, or a CS digital tuner, or a network interface receiving a program through the Internet. Here, a program to be received refers to information with at least video and audio data multiplexed and compressed for coding and, more specifically, an MPEG-2 (moving picture experts group phase 2) stream or an MPEG-4 stream.

The block device15is a device, such as a Blu-ray disk or a hard disk drive, having recorded thereon a program received by the program receiving part14. Here, the block device is a device in which data write and read are performed by a predetermined unit (a block unit). Inputs and outputs of data to and from the block device are performed through the file system.

The program replaying parts16each include a decoder161decoding video and audio streams of a program and a video and audio output part162outputting video and audio obtained as a result of decoding by the decoder161. In the present embodiment, the plurality of program replaying parts16are connectable to the bus17through a network connecting part not shown. The CPU11can supply the same program or can selectively supply separate programs to these plurality of program replaying parts16.

Software Structure of the Video-Recording and Replaying Apparatus

FIG. 2is a diagram of software structure of the video-recording and replaying apparatus100of the present embodiment.

In the video-recording and replaying apparatus100, an OS (operating system)31and a plurality of application programs (hereinafter referred to as applications)32operable on the OS31are present. Here, each application32is, for example, a program for video-recording a program, programs for normal replay, fast-forward replay, slow replay, frame-by-frame replay, and skip replay of a video-recorded program and, furthermore, a program for digest replay of automatically detecting a scene with a high degree of importance in a program and replaying highlights of the program.

The OS31includes, for example, a file system33, an I/O scheduler34, and a device driver35. A kernel of the OS31handles the application32being executed as a “task”, which is a unit of process execution.

In response to an I/O request for writing and reading a file from any of the applications32, the file system33converts this I/O request to an I/O request in a block format.

The I/O scheduler34is a scheduler for, by way of example, controlling the sequence of I/O requests from each task, coupling a plurality of I/O requests, and temporally controlling allocation of I/O resources for each task in order to improve efficiency of I/O processing on the block device15. The I/O scheduler34has a request queue for each task. To the request queue, a time slice predetermined for each task is set. The I/O scheduler34puts an I/O request in a block format received from a task through the file system into a corresponding request queue. At this time, the I/O scheduler34merges I/O requests to adjacent sectors into a single data structure called an I/O request for each same type (read request or write request). The I/O scheduler34selects one request queue with a round-robin scheme from among request queues for the respective tasks, selects one I/O request from the selected request queue, and passes the I/O request to the device driver35. This operation of the I/O scheduler34will be described in detail further below.

The device driver35executes a process requested by the I/O request selected by the I/O scheduler34on the block device15.

Operation of the I/O Scheduler34

FIG. 3is a conceptual diagram for describing the operation of the I/O scheduler34.

As depicted inFIG. 3, the I/O scheduler34has a request queue41for each task. The I/O scheduler34allocates a time slice predetermined for each task so that a total amount of I/O data for each task in each round-robin cycle for the block device15is approximately equal.

Here, since the amount of I/O data per unit time at fast-forward replay or digest replay is large compared with that at video-recording or normal replay, a time slice to be allocated to each task for fast-forward replay or digest replay is shorter than a time slice to be allocated to a task for video-recording or normal replay.

1. Registration in the Request Queue41

In response to an I/O request passed from the application32(the task) for writing or reading a file, the file system33converts the I/O request containing an identifier for identifying the requesting task into an I/O request in a block format, and passes the converted I/O request to the I/O scheduler34.

Based on the task identifier contained in the I/O request passed from the file system33, the I/O scheduler34generates or selects any one of the request queues41, and puts the I/O request in this request queue41. At this time, I/O requests to adjacent sectors are merged into a single data structure called an I/O request for each same type (read request or write request).

2. Supply of an I/O Request to the Device Driver35

The I/O scheduler34switches the request queue41from which an I/O request is passed to the device driver35with a round-robin scheme. The round-robin scheme is a scheme of sequentially and cyclically switching the request queue41from which an I/O request is passed to the device driver35. Since the request queue41is created for each task, switching the request queue41is hereinafter represented as task switching.

The processes of this flowchart are repeatedly executed.

Note that the sequence of round-robin task switching is set as, for example, a sequence of tasks where an I/O request occurs earliest first. When a task ends, the ended task is removed from the set task order sequence.

When switching the task (step S101), the I/O scheduler34starts a timer (step S102).

Next, the I/O scheduler34checks whether the request queue41of the task after switching retains an I/O request (step S103). When an I/O request is retained, the I/O request is selected and is passed to the device driver35, thereby executing that I/O request (step S104).

When the request queue41does not retain an I/O request, the I/O scheduler34enters in a standby state (step S106). When a new I/O request is registered in the request queue41within a predetermined time from the time when the I/O scheduler34enters in a standby state (YES at step S103), the I/O scheduler34selects that I/O request, and passes the I/O request to the device driver35. When no new I/O request is registered in the request queue41after a lapse of the predetermined time (YES at step S107), the I/O scheduler34switches the task, from which an I/O request is selected, to the next task (step S101). The I/O request selected from the request queue41is deleted from the request queue41. Note that the standby state does not continue over the time slice.

After completion of execution of the I/O request, the I/O scheduler34checks whether a current timer value is equal to or larger than a time slice value set in the request queue41(step S105). When the timer value is smaller than the time slice value set in the request queue41, the I/O scheduler34rechecks whether an I/O request is retained in the request queue41(step S103) and, when an I/O request is retained, selects and passes that I/O request to the device driver35. On the other hand, when the timer value is equal to or larger than the time slice value set in the request queue41, the I/O scheduler34switches the task, from which an I/O request is selected, to the next task (step S101). Also from then on, the processes described above are similarly repeated.

FIG. 5depicts an example of I/O scheduling of the present embodiment.

Here, r1-x, r2-x, and r3-xdenote I/O requests from a task1, a task2, and a task3, respectively. -x denotes a position in the sequence of the I/O requests. The round-robin sequence is assumed to be the task1, the task2, and then the task3. STM1, STM2, and STM3are time slices set to the task1, the task2, and the task3, respectively. These STM1, STM2, and STM3each have a value predetermined for each task so that a total amount of I/O data for each task in each round-robin cycle for the block device15is approximately equal. A relation in length among the time slices is assumed to be STM1>STM2. For example, the task1processes video-recording and the task2processes fast-forward replay. That is, since the amount of I/O data per unit time at fast-forward replay is larger than that at video-recording, when the time slices are determined so that a total amount of I/O data for each task in each round-robin cycle for the block device15is approximately equal, a time slice to be allocated to a task for fast-forward replay is shorter than a time slice to be allocated to a task for video-recording.

The I/O scheduler34selects an I/O request from the request queue41of the task1. The I/O scheduler34selects the I/O requests one by one from the request queue41of the task1within the time slice STM1and passes the I/O requests to the device driver35.

In the example ofFIG. 5, the case is depicted in which three I/O requests r1-1, r1-2, and r1-3are sequentially selected from the request queue41of the task1. After the third I/O request r1-3is executed, the request queue41of the task1temporarily becomes blank. Therefore, the I/O scheduler34enters a standby state with a predetermined time being taken as an upper limit. In this example, a new I/O request r1-4is newly registered in the request queue41of the task1before the predetermined time elapses after the I/O scheduler34enters a standby state. Therefore, the I/O scheduler34selects that I/O request r1-4. Then, since the request queue41of the task1becomes blank again, the I/O scheduler34enters a standby state again. Then, since no new I/O request is newly registered in the request queue41of the task1after a lapse of the predetermined time, the I/O scheduler34performs task switching.

Then, the I/O scheduler34selects an I/O request from the request queue41of the task2. In this example, the task2is a task having a relatively large amount of I/O data per unit time, such as fast-forward replay. Therefore, from the request queue41of the task2, the I/O requests r2-1, r2-2, r2-3, r2-4, and r2-5are successively selected during the time slice STM2. Here, the time slice STM2has elapsed before the end of execution of the final I/O request r2-5. When judging as such, the I/O scheduler34performs task switching.

Then, the I/O scheduler34selects an I/O request from the request queue41of the task3.

As described above, according to the I/O scheduling of the present embodiment, the time slice for each task is set so that a total amount of I/O data for each task in each round-robin cycle for the block device15is approximately equal. With this, when I/O resources for the block device are shared among tasks, nonuniformity of the amount of I/O data among tasks can be reduced. Therefore, multitasking in regard to video-recording and replaying can be excellently performed. For example, video-recording of a broadcast program can be excellently performed simultaneously with a process of reading a large amount of data for fast-forward replay, digest replay, or the like.

Also, according to the I/O scheduling of the present embodiment, when the request queue41of the task being selected is blank, task switching is performed before a lapse of the time slice. Therefore, use efficiency of I/O resources can be improved. Also from this point of view, multitasking in regard to video-recording and replaying can be excellently performed.

Modification Example

Next, a modification example of the embodiment described above is described.

In the embodiment described above, as described with reference toFIG. 5, only task switching is performed if the time slice STM2has elapsed before the end of execution of the final I/O request r2-5of the task2. An excess time from the time slice STM2at the end of execution of the I/O request r2-5delays the start of the next task processing. If such a delay occurs for each round-robin cycle, delays in timing of starting the next task processing gradually accumulate, thereby possibly degrading real-time properties of processing.

To get around this, a time obtained by subtracting the excess from the time slice from a default time slice is set as a time slice for the next round-robin cycle, then in a cycle subsequent to the next cycle, the time slice is back to the default time slice, and this series of processing is repeatedly performed. That is, two round-robin cycles are considered. In the first cycle, an excess from the default time slice is obtained. In the next cycle, a time obtained by subtracting the excess from the default time slice is adopted. Then, these two cycles are repeated. With this, an adverse effect on multitasking due to accumulation of excesses from the time slice can be avoided.

FIG. 6is a diagram for describing I/O scheduling of the modification example.

r1-x, r2-x, and r3-xdenote I/O requests from a task1, a task2, and a task3, respectively. The round-robin sequence is assumed to be the task1, the task2, and then the task3. STM1, STM2, and STM3are default time slices predetermined for each task so that a total amount of I/O data for each task in each round-robin cycle for the block device15is approximately equal.

In the first cycle of the two round-robin cycles, if the default time slice STM2has elapsed at the end of execution of the I/O request selected from the request queue of the task2, the I/O scheduler34calculates an excess time. That is, in the example ofFIG. 6, an excess time from the default time slice STM2at the end of execution of the I/O request r2-5is calculated.

In the second cycle of the two cycles, in place of the default time slice STM2, the I/O scheduler34adopts a time obtained by subtracting the excess time from the default time slice STM2as a corrected time slice STM2′. This can avoid accumulation of delays in timing of starting a process on a task subsequent to a task for performing I/O processing on the block device15at a high rate, such as fast-forward replay, and nonuniformity of the amount of I/O data among tasks can be more mitigated.

The present disclosure is not restricted to the embodiments described above, and can be variously modified within a scope not deviating from the gist of the present disclosure.