|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
一、cfg文件) T3 m3 Q( R0 [2 S$ E- n1 g
% m) H% V3 L1 z- Q# [' q7 c
- /* Create the stack Thread Task for our application. */
- var tskSlaveThread = Task.create("&slave_main");
- tskSlaveThread.stackSize = 0x2000;
- tskSlaveThread.priority = 0x5;
- tskSlaveThread.instance.name = "slave_main";0 q0 T' G+ l v4 ~
8 I5 {7 |! ^+ F0 A
5 T( L/ @7 s3 i创建slave_main进程。+ Q. _4 }5 R% V, D6 a3 w6 \
! f7 [* d9 J" D二、main函数
$ p1 U2 M; X. ^! y
4 M- C# h9 x& a9 J1 w' p! hmain函数很简单,只是打开IPC以及BIOS& ^, S2 P; W* R& D3 V. }
0 o* \' t( n" o
三、slave_main进程) L9 {3 E) U6 I" |
. _, K% D3 I- E% h1 e8 i3.1 创建heapBuf) X* }! a& Q8 r5 [3 [
$ R4 ~% E( F6 f" e! E7 J! q- /* Open the heap created by the other processor. Loop until opened. */
- do {
- status = HeapBufMP_open(IMAGE_PROCESSING_HEAP_NAME, &heapHandle); //"image_processing_heap"
- if (status < 0) {
- Task_sleep(1);
- }
- //printf("HeapBufMP_open failed\n" );
- } while (status < 0);. r8 H0 X8 i: l, I& p2 E; t5 u
9 e4 w" W- P4 N) h2 t
9 u8 ?" g! e; A2 j2 P, O; H, T3 @3.2 创建messageQ( slave )
+ D+ _" `5 Y& b! {7 o9 o
- |8 }' l) m0 G; I6 e+ k: U. v- /* Register this heap with MessageQ */
- MessageQ_registerHeap((IHeap_Handle)heapHandle, IMAGE_PROCESSING_HEAPID);
- /* Create the local message queue */
- //从核创建MessageQ 根据MessageQ名字 主核在MessageQ_open打开 MessageQ名字在mc_process_init中设置
- h_receive_queue = MessageQ_create(receive_queue_name, NULL);
- if (h_receive_queue == NULL)
- {
- printf("MessageQ_create failed\n" );
- goto close_n_exit;
- }) f. L; d) P( O9 i: E
& z( b: k2 T* g" C1 p8 k( q- ? |. V, d @0 O, b* R& w8 J6 d
3.3 接收messageQ( slave )- D `) m0 e6 M: w" {
& f* u8 ] X! ]( _+ K \1 L7 j" \& a- if (MessageQ_get(h_receive_queue, (MessageQ_Msg *)&p_msg, MessageQ_FOREVER) < 0) //接收MessageQ信息 通过p_msg结构体传输来 该结构体包含着 MessageQ头 核ID 图像处理参数
- {
- printf("%s: This should not happen since timeout is forever\n", receive_queue_name);
- goto close_n_exit;
- }
- reply_queue_id = MessageQ_getReplyQueue(p_msg); //获得回复队列的ID号 reply_queue_id 然后通过MessageQ_put发送出去
- if (reply_queue_id == MessageQ_INVALIDMESSAGEQ)
- {
- printf("receive_queue_name: Ignoring the message as reply queue is not set.\n", receive_queue_name);
- continue;
- }& {4 T# z: \/ X1 [0 ]& N% A
k" N4 M0 ~9 m' X) D3 f' A
3 L: i0 t: D3 {3.4 sobel图像处理9 j% W& @2 C5 R! J$ ]: U" \* Q" p
( V+ a/ ~1 o- {' ^2 cprocess_rgb(&(p_msg->info));; `! I: A7 s; v" _% o$ c: Q: r/ t
p_msg->info是该核需要处理的图像的指针,处理之后的结果也在这里( D- D2 @$ v4 h
& N3 v( {: n1 P/ `4 [$ T" K$ r1 d
3.5 发送messageQ( master)
# T" w q j: h+ o |) z7 E. D3 f' y0 P
- /*============== 向主核发送MessageQ信息===========*/
- if (MessageQ_put(reply_queue_id, (MessageQ_Msg)p_msg) < 0)
- {
- printf("%s: MessageQ_put had a failure error\n", receive_queue_name);
- }
- if (MultiProc_self() != 0)
- {
- Cache_inv(p_msg->info.scratch_buf[0], p_msg->info.scratch_buf_len[0], Cache_Type_ALL, FALSE);
- if (p_msg->info.scratch_buf[1])
- {
- Cache_inv(p_msg->info.scratch_buf[1], p_msg->info.scratch_buf_len[1], Cache_Type_ALL, FALSE);
- }
- Cache_inv(p_msg, sizeof(process_message_t), Cache_Type_ALL, FALSE);
- } ]/ W& _. L" [6 C% p b
5 O5 ]$ R7 a& [( t% p4 F- a 至此,大功告成5 [1 c) Q( W; V3 C A
( c! `; B! a4 Y# ?# I
. k0 I( b7 x# t' C" S/ F* ^& p' {$ @6 n4 ^* d2 _3 X6 e
6 G7 L. T$ Y" `3 }1 K+ N2 a
5 h! p- j ~5 x/ o" V4 I$ `5 W" V3 V4 v1 N1 K5 ?6 L8 }
% Z. I9 W8 R% X |
|