1

我正在尝试创建一个调度程序,并且在创建一个线程时,它给出了以下错误:

“DWORD (*)(LPVOID lpParameter)”类型的参数与“LPTHREAD_START_ROUTINE”类型的参数不兼容。

我按照其他问题中的建议将线程函数设为静态,但它仍然给出相同的错误。任何解决方案或指针将不胜感激。

这是我的代码的相关部分:

#include "stdafx.h"
#include <string>
#include <windows.h>
#include <vector>
#include <stdio.h>
#include <thread>

using namespace std;

struct process {
    int PID = 0;
    int burstTime;
    int arrivalTime;
    int priority;
};

vector<process> allProcesses;
process myProcess;

vector<HANDLE> handles;
vector<DWORD> dwords;

static DWORD myThread(LPVOID lpParameter)
{
    //execute my thread
}

void newArrival()
{
    DWORD tempThreadID;
    dwords.push_back(tempThreadID);

    ////error happens here at myThread
    handles.push_back(CreateThread(0, 0, myThread, &allProcesses[0], 0, &dwords[dwords.size() - 1]));

    //do even more stuff
}

void scheduler()
{
    //do some other stuff
    newArrival();
    //do more stuff
}

int main()
{
    //do some stuff

    myProcess.arrivalTime = 1000;
    myProcess.burstTime = 2500;
    myProcess.priority = 90;

    allProcesses = {myProcess};

    thread scheduler(scheduler);

    system("PAUSE > null");
    return 0;
}
4

0 回答 0