start_thread() 함수를 호출하려고합니다. 전달하고자하는 두 매개 변수는 void 함수 send와 portId 0의 주소입니다.하지만 계속 오류가 발생합니다. 'struct port_t *'가 필요하지만 인수는 'struct port_t *'threads.h입니다. 이 오류가 발생하는 이유는 무엇입니까?올바른 매개 변수 전달에 문제가 있음
typedef struct port_t {
int port[N];
semaphore_t producer, consumer, mutex;
int id;
} port_t;
int main()
{
port_t id[100];
int x;
for(x =0; x < 100; x++)
{
createPort(id[x], x);
}
start_thread(send, &id[0]);
}
int send(port_t temp)
{
while (1){
printf("Port %d: trying to send\n", temp.id);
P(&temp.consumer);
P(&temp.mutex);
printf("Port %d: sending message\n", temp.id);
V(&temp.mutex);
V(&temp.producer);
return 1;
}
}
void start_thread(void *function, struct port_t *port) //getting the message for this line
{
printf("In main: creating thread\n");
struct stack * stackP = (struct stack*)malloc(8192);
tcb = (struct TCB_t *)malloc(sizeof(struct TCB_t));
init_TCB (tcb, function, stackP, 8192, port);
tcb->val = port->id;
add_to_list(&ptr, &tcb);
}
컴파일러 오류에 대해 질문하는 경우 ** 완전한 ** 코드 집합을 게시하는 것이 좋습니다. 이 코드는 많은 경고와 오류를 발생시킵니다. 자세한 내용은 [도움말 센터 주제 MCVE] (http://stackoverflow.com/help/mcve)를 참조하십시오. – user3386109