我想在单独的核心上运行一个函数。我编写了一个脚本,可以异步并行运行两次。
const results = Channel()
function my_function()
delay = rand() * 5
@info "Task with $delay s"
@info "Thread $(Threads.threadid())"
sleep(delay)
put!(results, delay)
end
errormonitor(@async my_function())
errormonitor(@async my_function())
@info "returned $(take!(results))"
@info "returned $(take!(results))"
Run Code Online (Sandbox Code Playgroud)
但两次都在同一个线程中。
[ Info: Task with 2.9497522378270298 s
[ Info: Task with 4.956428193185428 s
[ Info: Thread 1
[ Info: Thread 1
[ Info: returned 2.9497522378270298
[ Info: returned 4.956428193185428
Run Code Online (Sandbox Code Playgroud)
如何my_function在不同的线程上运行?
我想在代码本身中获取闪存的限制地址,或者至少是该闪存的大小。
我在文件中只找到了flash的起始地址stm32f302xc.h,没有找到结束地址。
/** @addtogroup Peripheral_memory_map
* @{
*/
#define FLASH_BASE 0x08000000UL /*!< FLASH base address in the alias region */
#define SRAM_BASE 0x20000000UL /*!< SRAM base address in the alias region */
#define PERIPH_BASE 0x40000000UL /*!< Peripheral base address in the alias region */
#define SRAM_BB_BASE 0x22000000UL /*!< SRAM base address in the bit-band region */
#define PERIPH_BB_BASE 0x42000000UL /*!< Peripheral base address in the bit-band region */
Run Code Online (Sandbox Code Playgroud)
是什么定义对此负责,谢谢。
我有一个无法更改的函数,并且它需要 type ExpectedType。
function some_function(some_parameter::ExpectedType)
....
some implementation
....
end
Run Code Online (Sandbox Code Playgroud)
我想传递我的 type 对象OtherType。
我决定OtherType继承ExpectedType.
struct OtherType <: ExpectedType end
Run Code Online (Sandbox Code Playgroud)
但我收到一个错误:ERROR: invalid subtyping in definition of OtherType
我热衷于其他人的代码并想了解这里发生了什么。这个结构中存储了什么?
这是C中的某种模式吗?
typedef struct _P_NEXT P_NEXT;
struct _P_NEXT {P_NEXT *p_el;};
Run Code Online (Sandbox Code Playgroud)