BROWSE ARTICLES BY TECHNOLOGY

DIGITAL EDITION

RTC Magazine Digital Edition

INDUSTRY NEWS

RECENT COMMENTS

  • Hi Juan, This article shows you how to implement a quadrature encoder interface on the FPGA using digital lines. It was written for our PCI or P...

    Meghan Meckstroth Kerry - See Article

  • Good coverage on the general advantages of COM, and X86 implementations. It would have been nice to ARM options for lower-power (handheld) applicat...

    Brian Empey, P.Eng. - See Article

  • Your article about Application Service Platforms in RTC April is another example of great reporting by RTC. Can we have a new RTC index category -...

    Kenneth G Blemel - See Article

  • Static analysis tools/scanners are a great arsenal for companies who require high quality code. It does a great job of finding a wide range of pro...

    Andrew Yang - See Article

  • I hope that the microcessor based Insulin Pump riding on my belt would be held to a higher standard. If it quits, I can work around that inconvenie...

    Karl Williamson - See Article

WHITEPAPERS

QUICK DOWNLOADS

RTEC10 is an index made up of 10 public companies which have revenue that is derived primarily from sales in the embedded sector. The companies are made up of both software and hardware companies being traded on public exchanges.

COMPANY PRICECHANGE
Kontron
7.81
4.577%
Adlink
1.54
2.388%
Advantech
2.32
1.505%
Interphase
1.61
-3.012%
Radisys
9.26
-1.016%
-   Performance Technologies2.100.000%
-   Enea5.630.000%
PLX
3.62
-3.209%
Mercury Computer
11.76
-2.931%
Elma
412.98
-0.476%
HIGH LOW MKT CAP
7.85
7.43
435.04
1.58
1.52
185.11
2.33
2.30
1,198.70
1.70
1.61
11.00
9.41
9.24
223.74
2.102.1023.34
5.635.54101.86
3.74
3.61
134.28
12.17
11.76
279.57
412.98
412.98
94.25
RTEC10 Index: 490.94 (1.11%)
RTEC10 is sponsored by VDC research

TECHNOLOGY IN CONTEXT

Developing for Multi-Core Processors

Multi-Core Software: To Gain Speed, Eliminate Resource Contention

Even when applications are parallelized over multiple cores, performance can suffer from resource contention. Parallelizing the access to resources can eliminate much of the contention.

BY STEVE GRAVES, MCOBJECT

  • Page 1 of 3
    Bookmark and Share

Article Media

Deployment on multicore CPUs should make software faster by enabling tasks to run in parallel rather than waiting for a time slice on a single core. But in practice, parallel processing on multiple cores can introduce contention for system resources, making an application slower than when it is deployed on a single core. Achieving multicore’s hoped-for linear performance gains hinges on resolving this issue. By examining two examples of such a conflict and the proven solutions to them, we can get to the conceptual starting point for solutions to similar resource contention bottlenecks.

Database Contention

The first conflict is contention in updating a shared data store, and its solution is called multi-version concurrency control (MVCC). Until recently, nearly all database management solutions for embedded systems used a pessimistic concurrency model that locked all or portions of the database while a single task updated it, thereby blocking all other tasks from writing to the database (or portions of it) during the modification. In contrast, MVCC is an optimistic concurrency model in which no task or thread is ever blocked by another because each is given its own copy (version) of objects in the database to work with during a transaction. When a transaction is committed, its copy of the objects it has modified replaces the objects in the database. Because no explicit locks are ever required, and no task is ever blocked by another task with locks, MVCC can provide significantly faster performance in write-intensive applications where data must be changed often and where many tasks are running on multiple cores.

Under MVCC, when tasks want to update the same data at the same time, a conflict does arise and a retry will be required by one or more tasks. However, an occasional retry is far better, in performance terms, than the guaranteed blocking caused by pessimistic locking. Further, in most systems conflicts under MVCC are assumed to be infrequent because of the logically separate duties among tasks, that is, task A tends to work with a different set of data than tasks B, C and D, etc. 

Figure 1 compares MVCC to pessimistic locking, in operation. The diagram shows three tables in a database, each with five rows, and three tasks that are reading and/or modifying certain rows of certain tables. Task 1 is modifying Table 1’s row 3 (T1R3) and Table 2’s row 5 (T2R5).  Task 2 is modifying T3R1, T3R3 and T3R5. Task 3 is reading T3R3 and modifying T1R5 and T3R2. Note that there are two copies (versions) of T3R3: a copy in Task 2 and Task 3.  

Figure 1
Three tasks running in parallel have resulted in two versions of a database row (T3R3).

For purposes of this discussion, assume that all three tasks are started as close together in time as possible, but in the order Task 1, Task 2, Task 3. With MVCC, the three tasks run in parallel. With pessimistic locking, there are three possibilities: database locking, table locking and row locking. Each will exhibit different degrees of parallelism (but all less than MVCC).

Database locking: Task 1, Task 2 and Task 3 will be serialized. In other words, Task 1 will be granted access to the database while Task 2 and Task 3 are blocked as they “wait their turn.” When Task 1 completes its transaction, Task 2 will run while Task 3 continues to wait. Finally, Task 3 will run after Task 2 completes its transaction.

Table locking: Task 1 and Task 2 will run in parallel because Task 1 acquires locks on Table 1 and Table 2, while Task 2 acquires locks only on Table 3. Task 3 will block until Task 1 and Task 2 complete because it also needs a lock on Table 1 (which is locked by Task 1) and Table 3 (which is locked by Task 2). Task 3 will be blocked for the length of time required by Task 1 or Task 2, whichever is greater.

Row locking: Again, Task 1 and Task 2 will run in parallel because they operate on different tables, (hence on different rows). Task 3 will again block because Task 2 has a write lock on T3R3, which Task 3 wants to read. 

Any serialization effectively defeats a multicore system; all but one core will be idle with respect to the utilization of the shared resource (in this instance the database). However, strategies to maximize parallelism, such as MVCC or fine-grained locking, impose their own overhead. In the case of fine-grained locking (row locking) there is lock arbitration, which can be complex. In the case of MVCC, there is version management—creating object versions, merging them and discarding them. So for MVCC to be justified, the gain in parallelism has to outweigh the additional processing overhead. To illustrate, the graphs in Figures 2, 3 and 4 show the relative performance of McObject’s eXtremeDB in-memory database system on identical multithreaded tests executed on a multicore system, using a multiple-reader, single-writer (MURSIW, or database-locking) transaction manager, and its multi-version concurrency control (MVCC) transaction manager.

LEAVE A COMMENT