コード例 #1
0
void testcase5_g(void)
{
    int i = 0;

    while (1)
	{
        i++;

        if (i % 10000000 == 0)
		{
            printf("%s: id=%d: Current value i = %d\n", __FUNCTION__, GetMyId(), i);

			if (i == 10000000)
			{
				printf("%s: id=%d: Sleeping thread.\n", __FUNCTION__, GetMyId());
				SleepThread(2000);
			}

			if (i == 90000000)
			{
				printf("%s: id=%d: Deleteing thread 0. Return value = %d\n", __FUNCTION__, GetMyId(), DeleteThread(0));
			}

			if (i == 150000000)
			{
				CleanUp();
			}
        }
    }
}
コード例 #2
0
ファイル: TestFile4.c プロジェクト: P4RTI4L/Thread-Scheduler
void sleep_test()
{
    int i = 0;
    int j = 0;
    int sleep = 0;
    while(1)
    {
        if (sleep == 1)
        {
            printf("WAKING UP\n");
            sleep = 0;
        }
        if (i % 100000000 == 0)
        {
            int id = GetMyId();
            printf("sleep_thread tid: %d j = %d\n", id, j);
            j++;
        }
        if (j == 5)
        {
            j++;
            printf("SLEEP FOR 5 SECONDS (tid: %d)\n", GetMyId());
            sleep = 1;
            SleepThread(5);
        }
        i++;
    }
}
コード例 #3
0
ファイル: TestFile4.c プロジェクト: P4RTI4L/Thread-Scheduler
void suspend_test()
{
    int i = 0;
    int j = 0;
    while(1)
    {
        if (i % 100000000 == 0)
        {
            int id = GetMyId();
            printf("suspend_test tid: %d j = %d\n", id, j);
            j++;
        }
        if (j == 10)
        {
            j++;
            printf("SUSPEND THREAD 0\n");
            SuspendThread(0);
        }
        if (j == 20)
        {
            j++;
            printf("RESUME THREAD 0\n");
            ResumeThread(0);
        }
        i++;
    }
}
コード例 #4
0
void testcase5_h(void)
{
	int i = 0;

	while (1)
	{
		i++;

		if (i % 10000000 == 0)
		{
			printf("%s: id=%d: Current value i = %d\n", __FUNCTION__, GetMyId(), i);
		}

		if (i == 75000000)
		{
			printf("Creating thread. Thread ID=%d\n", CreateThread(testcase5_child_thread, 1));
			printf("%s: id=%d: Suspend thread %d. Return value = %d\n", __FUNCTION__, GetMyId(), GetMyId(), SuspendThread(GetMyId()));
		}
	}
}
コード例 #5
0
ファイル: TestFile4.c プロジェクト: P4RTI4L/Thread-Scheduler
void yield_test()
{
    int i = 0;
    int j = 0;
    while(1)
    {
        if (i % 100000000 == 0)
        {
            int id = GetMyId();
            printf("yield_test tid: %d j = %d\n", id, j);
            j++;
        }
        if (j % 5 == 0)
        {
            j++;
            printf("YIELDING CPU tid: %d\n", GetMyId());
            YieldCPU();
        }
        i++;
    }
}
コード例 #6
0
ファイル: TestFile4.c プロジェクト: P4RTI4L/Thread-Scheduler
void delete_test()
{
    int i = 0;
    int j = 0;
    while(1)
    {
        if (i % 100000000 == 0)
        {
            int id = GetMyId();
            printf("delete_test tid: %d j = %d\n", id, j);
            j++;
        }
        if (j % 25 == 0)
        {
            j++;
            printf("DELETING MYSELF tid: %d\n", GetMyId());
            DeleteThread(GetMyId());
        }
        i++;
    }
}
コード例 #7
0
void testcase5_child_thread(void)
{
	int i = 0;

	while (1)
	{
		i++;

		if (i % 10000000 == 0)
		{
			printf("%s: id=%d: Current value i = %d\n", __FUNCTION__, GetMyId(), i);
		}
	}
}
コード例 #8
0
ファイル: TestFile4.c プロジェクト: P4RTI4L/Thread-Scheduler
void simple_thread()
{
    int i = 0;
    int j = 0;
    while(1)
    {
        if (i % 100000000 == 0)
        {
            int id = GetMyId();
            printf("simple_thread tid: %d j = %d\n", id, j);
            j++;
        }
        if (j == 30)
        {
            printf("CLEANUP()\n");
            CleanUp();
        }
        i++;
    }

}
コード例 #9
0
ファイル: TestFile4.c プロジェクト: P4RTI4L/Thread-Scheduler
void create_test()
{
    int i = 0;
    int j = 0;
    while(1)
    {
        if (i % 100000000 == 0)
        {
            int id = GetMyId();
            printf("create_test tid: %d j = %d\n", id, j);
            j++;
        }
        if (j == 30)
        {
            j++;
            printf("CREATING A NEW THREAD\n");
            CreateThread(simple_thread, 1); 
        }
        i++;
    }
}
コード例 #10
0
ファイル: TestFile4.c プロジェクト: P4RTI4L/Thread-Scheduler
void delete_other_test()
{
    int i = 0;
    int j = 0;
    while(1)
    {
        if (i % 100000000 == 0)
        {
            int id = GetMyId();
            printf("delete_other_test tid: %d j = %d\n", id, j);
            j++;
        }
        if (j == 20)
        {
            j++;
            printf("DELETING THREAD 1\n");
            DeleteThread(1);
        }
        i++;
    }
}
コード例 #11
0
void testcase5_f(void)
{
    int i = 0;

	printf("%s: id=%d: Yielding CPU when i > 10000000\n", __FUNCTION__, GetMyId());

    while (1)
	{
        i++;

        if (i > 10000000)
		{
			YieldCPU();
        }

		if (i % 10000000 == 0)
		{
			// don't create tcb on stack. Stack size is too small
			ut_tcb_t *tcb = malloc(sizeof(ut_tcb_t));
			printf("%s: id=%d: Getting status of current thread. Return value = %d\n", __FUNCTION__, GetMyId(), GetStatus(GetMyId(), tcb));
			ut_tcb_print_info(tcb, true);
		}
    }
}
コード例 #12
0
ファイル: ExportManager.cpp プロジェクト: kmdtukl/miranda-ng
bool ExportManager::Export(IExport::ExportType type)
{
	exp = NULL;
	UINT cp;
	std::wstring encoding;
	bool isBin = false;
	switch(type) {
	case IExport::Txt:
		exp = new TxtExport();
		cp = Options::instance->codepageTxt;
		encoding = Options::instance->encodingTxt;
		isFlat = true;
		break;
	case IExport::PlainHtml:
		exp = new PlainHtmlExport();
		cp = Options::instance->codepageHtml1;
		encoding = Options::instance->encodingHtml1;
		break;
	case IExport::RichHtml:
		exp = new RichHtmlExport();
		cp = Options::instance->codepageHtml2;
		encoding = Options::instance->encodingHtml2;
		break;
	case IExport::Binary:
		exp = new BinaryExport();
		cp = CP_UTF8;
		encoding = L"UTF8";
		isFlat = true;
		oldOnTop = true;
		isBin = true;
		break;
	case IExport::Dat:
		exp = new DatExport();
		cp = CP_UTF8;
		encoding = L"UTF8";
		isFlat = true;
		oldOnTop = true;
		isBin = true;
		break;
	default:
		return false;
	}

	std::wstring fileName;
	if (file.empty())
		fileName = GetFile(exp->GetExt(), hwnd, false);
	else
		fileName = ReplaceExt(file, exp->GetExt());

	if (fileName.empty())
		return false;

	std::wofstream* stream;
	if (!isBin) {
		stream = new std::wofstream (fileName.c_str());
		if (!stream->is_open())
			return false;
	
		std::locale filelocale(std::locale(), new codecvt_CodePage<wchar_t>(cp));
		stream->imbue(filelocale);
		exp->SetStream(stream);
	}
	else {
		std::ofstream* cstream = new std::ofstream (fileName.c_str(), std::ios_base::binary);
		if (!cstream->is_open())
			return false;
	
		stream = (std::wofstream*)cstream;
		exp->SetStream(stream);
	}

	exp->WriteHeader(fileName, GetFilterName(), GetMyName(), GetMyId(), GetContactName(), GetProtocolName(), GetContactId(), GetBaseProtocol(), encoding);

	RefreshEventList();

	exp->WriteFooter();
	if (!isBin) {
		stream->close();
		delete stream;
	}
	else {
		std::ofstream* cstream = (std::ofstream*)stream;
		cstream->close();
		delete cstream;
	}

	delete exp;
	return true;
}