synchronized知识梳理

用户态与内核态

JDK早期,synchronized 叫做重量级锁, 因为申请锁资源必须通过kernel, 系统调用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
;hello.asm
;write(int fd, const void *buffer, size_t nbytes)

section data
msg db "Hello", 0xA
len equ $ - msg

section .text
global _start
_start:

mov edx, len
mov ecx, msg
mov ebx, 1 ;文件描述符1 std_out
mov eax, 4 ;write函数系统调用号 4
int 0x80

mov ebx, 0
mov eax, 1 ;exit函数系统调用号
int 0x80

:D 一言句子获取中...