Esempio n. 1
0
status_t
DebugReportGenerator::_DumpSemaphores(BFile& _output)
{
	BObjectList<SemaphoreInfo> semaphores(20, true);
	status_t error = fDebuggerInterface->GetSemaphoreInfos(semaphores);
	if (error != B_OK)
		return error;

	semaphores.SortItems(&_CompareSemaphores);

	BString data = "\nSemaphores:\n";
	WRITE_AND_CHECK(_output, data);
	data.SetToFormat("\tID\t\tCount\tLast Holder\tName\n\t");
	WRITE_AND_CHECK(_output, data);
	data.Truncate(0L);
	data.Append('-', 60);
	data.Append("\n");
	WRITE_AND_CHECK(_output, data);
	SemaphoreInfo* info;
	for (int32 i = 0; (info = semaphores.ItemAt(i)) != NULL; i++) {
		try {
			data.SetToFormat("\t%" B_PRId32 "\t%5" B_PRId32 "\t%11" B_PRId32
				"\t%s\n", info->SemID(), info->Count(),
				info->LatestHolder(), info->Name().String());

			WRITE_AND_CHECK(_output, data);
		} catch (...) {
			return B_NO_MEMORY;
		}
	}

	return B_OK;
}
Esempio n. 2
0
/** entry point
 @param argc the number of arguments starting with the programme name
 @param argv the arguments
 @return     either EXIT_SUCCESS or EXIT_FAILURE */
int main(int argc, char **argv) {
	int i;
	int jobs = 3, clients = 4, printers = 2; /* defualt */
	int is_wtf = 0;
	char c;
	extern char *optarg;
	extern int optind;

	/* parse command line */
	while((c = getopt(argc, argv, "c:p:b:h")) != -1) {
		switch(c) {
			case 'c':
				clients = atoi(optarg);
				break;
			case 'p':
				printers = atoi(optarg);
				break;
			case 'b':
				jobs = atoi(optarg);
				break;
			case 'h':
				usage();
				return EXIT_SUCCESS;
			case '?':
				is_wtf = -1;
				break;
		}
	}
	if(is_wtf || optind != argc || jobs < 1 || clients < 1 || printers < 1) {
		usage();
		return EXIT_FAILURE;
	}

	/* seed the random */
	srand(clock());

	/* semaphores */
	if(!semaphores(jobs)) return EXIT_FAILURE;
	atexit(&semaphores_);

	/* print stuff with multiple threads */
	if(!(the_spool = Spool(jobs, printers, clients))) return EXIT_FAILURE;
	for(i = 0; i < printers; i++) PrinterRun(the_spool->printer[i]);
	/* fixme: the printers have to be started first, I think */
	for(i = 0; i < clients;  i++) ClientRun(the_spool->client[i]);
	Spool_(&the_spool);

	printf("Shutting down.\n");

	return EXIT_SUCCESS;
}
Esempio n. 3
0
void surface_semaphore_test(skiatest::Reporter* reporter,
                            const sk_gpu_test::ContextInfo& mainInfo,
                            const sk_gpu_test::ContextInfo& childInfo1,
                            const sk_gpu_test::ContextInfo& childInfo2,
                            bool flushContext) {
    GrContext* mainCtx = mainInfo.grContext();
    if (!mainCtx->caps()->fenceSyncSupport()) {
        return;
    }

    const SkImageInfo ii = SkImageInfo::Make(MAIN_W, MAIN_H, kRGBA_8888_SkColorType,
                                             kPremul_SkAlphaType);

    sk_sp<SkSurface> mainSurface(SkSurface::MakeRenderTarget(mainCtx, SkBudgeted::kNo,
                                                             ii, 0, kTopLeft_GrSurfaceOrigin,
                                                             nullptr));
    SkCanvas* mainCanvas = mainSurface->getCanvas();
    mainCanvas->clear(SK_ColorBLUE);

    SkAutoTArray<GrBackendSemaphore> semaphores(2);
#ifdef SK_VULKAN
    if (kVulkan_GrBackend == mainInfo.backend()) {
        // Initialize the secondary semaphore instead of having Ganesh create one internally
        GrVkGpu* gpu = static_cast<GrVkGpu*>(mainCtx->contextPriv().getGpu());
        const GrVkInterface* interface = gpu->vkInterface();
        VkDevice device = gpu->device();

        VkSemaphore vkSem;

        VkSemaphoreCreateInfo createInfo;
        createInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
        createInfo.pNext = nullptr;
        createInfo.flags = 0;
        GR_VK_CALL_ERRCHECK(interface, CreateSemaphore(device, &createInfo, nullptr, &vkSem));

        semaphores[1].initVulkan(vkSem);
    }
#endif

    if (flushContext) {
        mainCtx->flushAndSignalSemaphores(2, semaphores.get());
    } else {
        mainSurface->flushAndSignalSemaphores(2, semaphores.get());
    }

    sk_sp<SkImage> mainImage = mainSurface->makeImageSnapshot();
    GrBackendTexture backendTexture = mainImage->getBackendTexture(false);

    draw_child(reporter, childInfo1, backendTexture, semaphores[0]);

#ifdef SK_VULKAN
    if (kVulkan_GrBackend == mainInfo.backend()) {
        // In Vulkan we need to make sure we are sending the correct VkImageLayout in with the
        // backendImage. After the first child draw the layout gets changed to SHADER_READ, so
        // we just manually set that here.
        GrVkImageInfo vkInfo;
        SkAssertResult(backendTexture.getVkImageInfo(&vkInfo));
        vkInfo.updateImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
    }
#endif

    draw_child(reporter, childInfo2, backendTexture, semaphores[1]);
}