1589 views|4 replies

6388

Posts

8

Resources
The OP
 

Reading check-in station 8: memory barrier instructions, operating system - "RISC-V architecture programming and practice" [Copy link]

Activity details: Read "RISC-V Architecture Programming and Practice" together

This is the eighth stop for the reading and checking-in for "RISC-V Architecture Programming and Practice". Please reply to the author and ask the following questions.

Benshu helps you check in with your reading questions (reminder: read chapters 15, 16, and 17 of the book ):

34. What is the cause of memory disorder?
35. Please briefly describe the role and usage scenarios of the FENCE.I instruction and the SFENCE.VMA instruction.
36. What is process context switching? For RISC-V processors, what content needs to be saved for process context switching? Where is it saved?
37. Assuming that the scheduler switches process A to process B through the switch_to() function, does process B immediately execute the callback function of thread B after the switch is completed?

Friends who participated in the event, the reading check-in is about to end, let’s continue~

@jobszheng5 @1nnocent @子期非女 @常见泽1 @我爱下载

This post is from Embedded System
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle

Latest reply

I have learned it, and this kind of learning is more effective!   Details Published on 2023-8-24 10:04
Personal signature微信搜索公众号“EEWORLDBBS”快去添加关注吧!

7172

Posts

195

Resources
2
 

34. What causes memory disorder?

____

If the actual memory access order of the program during execution is inconsistent with the access order specified by the program code, out-of-order memory access will occur.

Usually the program order is not equal to the memory order, resulting in out-of-order memory access


35. Please briefly describe the functions and usage scenarios of the FENCE.I instruction and the SFENCE.VMA instruction.

--------

The FENCE.I instruction is used as a synchronization primitive between cache instructions and prefetch instructions in the same CPU. In simple terms, it ensures that when the store instruction is visible to the CPU, the prefetch instruction is also visible to the CPU.

A simple implementation refreshes the local CPU's instruction cache and instruction pipeline. A more complex implementation can perform cache migration monitoring for each data instruction cache miss.

The SFENCE.VMA instruction constrains the order of memory accesses to ensure the correct execution of memory operations.


36. What is a process context switch? For RISC-V processors, what content needs to be saved during process context switching? Where is it saved?

——————

Switch from one process to the next process

The context that needs to be saved includes the values of S0-S11 registers, SP register, and ra register. Save them to task_struct->cup_context of the Netx process, and then restore the values of these registers in the processor from task_struct->cpu_context of the next process.


37. Assume that the scheduler switches process A to process B through the switch_to() function, then does process B immediately execute the callback function of thread B after the switch is completed?

_______

Some finishing work needs to be done for the kernel line layer A that has just been scheduled

This post is from Embedded System
 
 

336

Posts

2

Resources
3
 


34. What is the cause of memory disorder? When
the actual memory access order of the program is inconsistent with the order specified by the program code during execution, memory disorder will occur.

35. Please briefly describe the role and usage scenarios of the FENCE.I instruction and the SFENCE.VMA instruction.
The role of FENCE.I is to ensure that the storage operation before the barrier has been completed and applied to the local CPU. The
role of SFENCE.VMA is to implement the synchronization operation of virtual memory management. The application scenarios are: 1) when the software changes the ASID of the process; 2) if the processor does not implement ASID or uses an ASID with a value of 0, when updating the satp register; 3) if the software modifies the page table entry outside the PTE; 4) if the software modifies the page table entry.
36. What is process context switching? For RISC-V processors, what content needs to be saved for process context switching? Where is it saved?
Process context switching refers to switching from the previous process to the next process through the switch function switch_to(), saving the context of the previous process during the switching process, and restoring the context of the next process.
The register contents that need to be saved are S0~S11, sp and ra, and saved to the cpu_context of the previous process.
37. Suppose the scheduler switches process A to process B through the switch_to() function. Then, does process B immediately execute the callback function of thread B after the switch is completed?
The callback function of thread B cannot be executed immediately, and some finishing work needs to be done for process A.

This post is from Embedded System
 
 
 

623

Posts

0

Resources
4
 

34. Reply: In general, program order is not equal to memory order, resulting in memory disorder.
35. Reply: The FENCE.I instruction is used as a synchronization primitive between cache instructions and prefetch instructions in the same CPU. The goal is to ensure that when the store instruction is visible to the CPU, the prefetch instruction is also visible to the CPU. The SFENCE.VMA instruction constrains the memory access order of memory operations in order to ensure that memory operations are executed correctly.

This post is from Embedded System
 
 
 

6841

Posts

11

Resources
5
 

I have learned it, and this kind of learning is more effective!

This post is from Embedded System
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
Design of traffic light controller based on single chip microcomputer

Design of a single-chip traffic light controller 1. Design task Set up traffic lights at a crossroads and use a single-c ...

What are the difficulties in designing DC power modules?

author: Happy Jianghu: I think: 1. Heat treatment. This should be the biggest limitation of power module desi ...

IP address conflicts are a headache, but there is a trick to solve it

This post was last edited by jameswangsynnex on 2015-3-3 20:01 When the error "The computer detected a conflict between ...

DIY ImxRT1010 board, sharing hardware debugging experience

This post was last edited by RCSN on 2019-12-8 22:59 According to the previous post, the host bought the MIMXRT1010-EV ...

Parts information management system Musecad CircuiteXpert - solves parts usage, library management, auditing, plug-in failure, BOM...

This post was last edited by musecad on 2020-8-15 12:05 As a long-established schematic design tool, Capture is powerfu ...

FPGA introductory series experimental tutorial - key debounce control LED on and off

505224

【Me and gui-guider②】Button control

This post was last edited by RCSN on 2021-3-20 21:19 The word "botton" means button, and it also acts as a switch in LG ...

Recruitment: Ningbo listed auto parts company - motor control software development engineer

Recruiting motor control software development engineers Salary range: 15-25K/month before tax*14 Job Responsibilities: 1 ...

Review Weekly Report 20220110: More convenient than BLE, more flexible than NFC, a new product suitable for big data ST60 Actual test & application last 2 days

This week's review highlights: -Applications closed in the past 2 days: Experience ST live broadcast of new products, bi ...

[HPM-DIY] openmv for hpm6750 Progress 2 (face recognition 29fps+)

Openmv for hpm has been updated by the author in the past few days, mainly fixing the following: 644525 In addition, us ...

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list