Single block read, block read

Source: Internet
Author: User

Single block read, block read

What is single read? As the name implies, a single block can be read by a single block. The waiting event is db file sequential read. What are the situations of a single block read? Most index scans are for a single read (except for index fast full scan). The rowid returned to the table is for a single read, and the read data in undo is for a single read, the row link for row migration is a single-block read, The read header is a single-block read, and the read boundary block is a single-block read. Now we will discuss whether undo reads data in a single block: -- session1: SQL> begin 2 for x in 1 .. 1000000 loop 3 update t set id = 999; 4 end loop; 5 commit; 6 end; 7/it has been executed for too long and no result is returned -- session2: SQL> select count (*) from t; -- session3: SQL> @ getsession_mySID_SERIAL SQL _ID_NUM P_NAME P_VALUE EVENT SQL _TEXT MINUTE1 MINUTE_EXEC INST_ID USERNAME ---------------------------------------------------------------------------------------------------- ---------- ----------- ---------- MACHINE---1, 7 7kyc4rsrd3q1b, 0 address 837617808 latch: cache buffers chai update t set id = 999 469.68 7.1 1 SCOTT number 150 ns tries 0lhj29, 871 cyzznbykb509s, 0 file #3 db file sequential read select count (*) from. 98. 58 1 SCOTT block #398158 t blocks 1lhj2 rows selected. elapsed: 00:00:00. 09 -- Here select count (*) from t corresponds to the waiting time db file sequenti Al read -- check again later for the same SQL> @ getsession_mySID_SERIAL SQL _ID_NUM P_NAME P_VALUE EVENT SQL _TEXT MINUTE1 MINUTE_EXEC INST_ID USERNAME ---------- too many bytes ------------ -------------- ------------ MACHINE -------- ---1, 7 7kyc4rsrd3q1b, 0 count 1 Data file init write update t set id = 999 470.17 7.58 1 SCOTT intr 256 timeo Ut 4294967295lhj29, 871 cyzznbykb509s, 0 file #3 db file sequential read select count (*) from 1.47 1.07 1 SCOTT block #419088 t blocks 1lhj2 rows selected. elapsed: 00:00:00. 01 -- file # Corresponds to the undo tablespace SQL> select file_id, tablespace_name from dba_data_files where file_id = 3; FILE_ID TABLESPACE_NAME ---------- tablespace 3 UNDOTBS1 -- visible corresponds to the undo tablespace 1 row selected. elapsed: 00:00:11. 88. dml At this time, a query about the table is sent. If the queried data is just dml data, it is read from the undo tablespace. Undo has the following advantages and disadvantages: It ensures data accuracy. before modifying data, oracle copies the data to be modified to the undo tablespace, if the transaction succeeds, undo can be released and reused. If the transaction fails, it will be rolled back and forth to dml through undo. This is a unique mechanism of oracle. The disadvantage is that reading data in undo is a single read, and the speed is very slow. This is why recovery takes a long time after many databases are down.


For reading and writing SD card on the STM32 chip, reading and writing of a single block is OK, but reading and writing of multiple blocks is always unsuccessful.

What chip are you using? Is it stm32f103vrt6?

For commands in spi Mode

7 SPI Mode

7.1 Introduction

The SPI mode consists of a secondary communication protocol based on the flash SD memory card. This mode is a subset of the SD memory card protocol. This interface is selected during each reset command after power-on (power-on 0.

The SPI standard only defines physical connections, but does not provide data transmission protocols. SD memory card SPI execution utilizes the SD memory card protocol and a subset of the command set.

7.2 SPI bus protocol

The SD card is based on commands and Data Streams. These commands and data streams start with a starting bit and end with a stopping bit. the SPI channel is byte-oriented. each Command or data block is composed of multiple 8-bit bytes, and each byte is aligned with the chunk signal (for example, this length is a multiple of 8 clock cycles ).

Similar to the SD memory card protocol, SPI short messages are composed of commands, responses, and data block rings. All communication is controlled by the host, and the host starts each bus transaction by lowering the CS.

The Response Behavior in SPI mode is different from that in SD mode in three aspects:

1. The selected card always responds to the command.

2. Use an additional (8-bit) response structure.

3. When a card encounters a data retrieval problem, it will respond with a response error (replacing the expected data block) instead of a timeout in SD mode.

In addition to the command response, each data block sent to the card during the write operation is responded with a special data response token. A data block may be as big as a write block (WRITE_BL_LEN) or as small as a signal word. Some block read/write operations are enabled by the selected items described in the CSD register in the card.

7.2.1 Mode Selection

SD card wake-up from SD mode. If the CS signal is lowered during the reception of the reset command (reset 0) and enters the idle mode, the command is not responded if it is considered to be required in SD mode, and is still in SD mode. If the SPI mode is required, the card switches to the SPI mode and responds with the SPI mode R1.

The only way to return SD mode is to enter the power-on period. In SPI mode, the SD memory card Protocol state machine is not observed. All SD memory card commands supported in SPI mode are always available.

7.2.2 bus transmission protection

Each SD memory card token transmitted on the bus is protected by CRC bits. In SPI mode, the SD memory card provides a non-protection mode. This mode enables the system to establish with reliable data links to exclude (deny) hardware or software that requires CRC generation and verification.

In unprotected mode, the CRC bits of the command, response, and data token are still needed in the token, although they are defined as "don't care" for the sender ", and ignored by the receiver.

In unprotected mode, the SPI interface is initialized. Although the RESET command is used to switch the card to the SPI mode, it is received by the card in SD mode, so there must be a valid CRC Field.

Because limit 0 does not have a parameter, the content of all fields (including CRC fields) are constants and do not need to be calculated during runtime. A valid reset command is:

0x40, 0x0, 0x0, 0x0, 0x0, 0x95

The host can use the CRC_ON_OFF command (000059) to switch the CRC option of the card.

7.2.3 read data

SPI supports single-block read and multi-block read operations (for example, limit 17 OR limit 18 in the SD memory card protocol ). After receiving a valid READ command, the system uses a response token after a data token with the length defined by SET_BLOCK_LEN (Limit 16. (Refer to Figure41)

Figure41 single-block read Operations

A valid data block is added with a 16-bit CRC, which is generated by the CCITT standard polynomial X16 + X12 + X5 + 1.

It can be defined by the length of the largest block given by READ_BL_LEN in CSD. If the part is allowed, the part length can be 1 ~ Any length between the MAX block size. Otherwise, the valid block length for Data Reading is only the value given in READ_BL_LEN.

The starting address can be any byte address within the valid address range of the card. However, each block must contain... the remaining full text>
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.