小编pet*_*lin的帖子

如何在c中的链接描述文件中访问变量?

在链接器脚本中,我定义了PROVIDE(__KERNEL_BEGIN__ = .);.

地址可以从以下地址访问:

extern uint32_t __KERNEL_BEGIN__[];
Run Code Online (Sandbox Code Playgroud)

但是,以下不起作用(给出错误的地址):

extern uint32_t * __KERNEL_BEGIN__;
Run Code Online (Sandbox Code Playgroud)

我看着集会.第一种方法__KERNEL_BEGIN__提供了确切的地址.第二个,__KERNEL_BEGIN__ = [address]在地址处查找值.

那么,一定是这样吗?我无法区分.

c gcc ld

4
推荐指数
2
解决办法
2263
查看次数

sync.Pool比使用channel慢得多,那么为什么要使用sync.Pool?

我读了sync.Pool设计,但发现有两种逻辑,为什么我们需要localPool来解决锁竞争。我们可以使用chan来实现一个。

使用频道的速度是的4倍sync.pool

除了池可以清除对象外,它还有什么优势?

这是池实现和基准测试代码:

package client

import (
    "runtime"
    "sync"
    "testing"
)

type MPool chan interface{}


type A struct {
    s        string
    b        int
    overflow *[2]*[]*string 

}

var p = sync.Pool{
    New: func() interface{} { return new(A) },
}

var mp MPool = make(chan interface{}, 100)

func get() interface{} {
    select {
    case r := <-mp:
        return r
    default:
        return new(A)
    }
}

func put(a interface{}) {
    select {
    case mp <- a:
    default:
    }
    return …
Run Code Online (Sandbox Code Playgroud)

benchmarking synchronization pool channel go

0
推荐指数
1
解决办法
765
查看次数

标签 统计

benchmarking ×1

c ×1

channel ×1

gcc ×1

go ×1

ld ×1

pool ×1

synchronization ×1