/* * Performance test program for Vector Font Library VFlib 2 * * This program measures the drawing time of outline data. * (not including reading time of outline from disk.) * * * Programmed by Hirotsugu KAKUGAWA, Hiroshima University * E-Mail: kakugawa@se.hiroshima-u.ac.jp * * Edition History * 22 Jan 1994 * 11 Mar 1994 version 2 New performance test * */ /* This file is part of VFlib * * Copyright (C) 1993,1994 Hirotsugu KAKUGAWA. All rights reserved. * * VFlib is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY. No author or distributor accepts responsibility * to anyone for the consequences of using it or for whether it serves any * particular purpose or works at all, unless he says so in writing. Refer * to the GNU General Public License for full details. * * Everyone is granted permission to copy, modify and redistribute * VFlib, but only under the conditions described in the GNU * General Public License. A copy of this license is supposed to have been * given to you along with VFlib so you can know your rights and * responsibilities. It should be in a file named COPYING. Among other * things, the copyright notice and this notice must be preserved on all * copies. */ /*** *** CAUTION!! THIS FILE CONTAINS 8-BIT EUC KANJI CHARACTER CODES ***/ /** KANJI CODE (EUC/SJIS) **/ #define EUC #undef SJIS #include #include #include #include #include "../src/VF.h" #include "../src/defs.h" #include "str.h" /* Default Pixel Size */ #define W_XDOTS 100 #define W_YDOTS 100 int ToJIS(unsigned char *s); /** THIS IS EUC KANJI TEXT **/ /* 角川裕次 山下雅史 (広島大学工学部第二類), "分散システムでの資源割り当てアリゴリズム", 1994 年 冬の LA シンポジウム予稿より一部抜粋. */ static char *TestString = "角川裕次山下雅史(広島大学工学部第二類)\ 分散システムでの資源割り当てアリゴリズム\ 1994年冬のLAシンポジウム予稿より一部抜粋\ \ 概要\ 本稿では,分散システムでの共有資源の割り当て問題を考察する.プロセス毎\ に使用可能な共有資源が異なる,というモデルに対する資源割り当て問題を解\ くために,局所コータリーという構造を新たに提案する.また,局所コータ\ リーを用いた資源割り当てを行なう分散アルゴリズムを提案し, その正当性\ を示す.\ \ Keywords:\   resource allocation,\   mutual exclusion,\   critical section,\   distributed system\ はじめに\ 複数のプロセスが地理的に分散しそれらが互いに通信をしながら情報交換を行\ なう分散システムに於ける資源の共有を考える.  共有される資源は排他的\ な使用, 即ち2つ以上のプロセスは1つの資源を同時に使用する事が出来な\ いと仮定する.資源が分散システム全域で共有される場合は従来からよく研究\ されてきている.例えば, 分散データベースでは, データ項目を1つの共\ 有資源と見倣すことが出来る. そして, データの更新を行なう為に資源を\ 確保すれば, 他のプロセスが資源を確保していない事が保証されるので, \ データの一貫性を失うことなく更新作業を行なう事が出来る.\ \ 従来の研究では, 1つの資源が分散システム全域で共有されるという資源共\ 有のモデルが取り扱われ, 資源へのアクセスを行なう(臨界領域にある)プ\ ロセスの数を各時点において高々1つに制限する分散相互排除問題として研究\ されてきた[lamport78][ricart81][garcia8\ 5] [suzuki85][maekawa85][agrawal89]\ [raymond89b].  Lamport [lamport78],\ Ricart [ricart81]によって提案された分散相互排除アルゴ\ リズムは, 相互排除を行なう度に全てのプロセスにメッセージを送らねばな\ らず, メッセージ数や耐故障性の点より好ましくない.Garcia−Mo\ linaら[garcia85]はコータリー (coterie) という\ 構造を提案し, メッセージを送るべきプロセスの集合が必ずしも全てのプロ\ セスではなく, 一部のプロセスのみでも相互排除を保証することができる事\ を示した.前川[maekawa85]は, 相互排除を行なうために送るべ\ きメッセージ数が O(n**0.5) で済むコータリーの構成法と分散相\ 互排除アルゴリズムを示した.  ここで n は分散システムに含まれるプ\ ロセスの数である."; /** END OF KANJI STRING **/ int main(int argc, char **argv) { int Repeat, Fd, Ccode, i; int XDots, YDots, XBytes, DispC, UseFSlib; char *Ent, *Vfcap, *Comment; char *Buff; long *vfdata, *VFTable[2000]; unsigned char *p; struct tms t_start, t_end; Vfcap = NULL; Ent = "min"; XDots = W_XDOTS; YDots = W_YDOTS; DispC = 0; UseFSlib = 0; Comment = ""; for (i = 1; i < argc; i++){ if (argv[i][0] == '-') switch (argv[i][1]){ case 'c': Comment = argv[++i]; break; case 'd': DispC = 1; break; case 'f': Ent = argv[++i]; break; case 'F': UseFSlib = 1; break; case 'x': XDots = atoi(argv[++i]); break; case 'y': YDots = atoi(argv[++i]); break; case 'v': Vfcap = argv[++i]; break; case 'h': default: printf("vfperf - performance test program for VFlib 2\n"); printf("Usage vfperf [options]\n"); printf("Options:\n"); printf("-c COMMENT : comment.\n"); printf("-d : display char codes.\n"); printf("-F : use FS_scan_conv() of FSlib to draw.\n"); printf("-f FONT_ENTRY : specify font entry name. (`min' is default)\n"); printf("-x DOTS : set character width.\n"); printf("-y DOTS : set character height.\n"); printf("-v : set vfontcap file. (must give full path)\n"); exit(0); } } XBytes = (XDots+7)/8; if ((Buff = malloc(XBytes*YDots)) == NULL){ fprintf(stderr, "malloc err\n"); exit(0); } VF_Init(Vfcap); if ((Fd = VF_OpenFont(Ent)) < 0){ fprintf(stderr, "open error; %s\n", Ent); exit(-1); } /*** Read Outline Data ***/ i = 0; p = (unsigned char*) TestString; vfdata = NULL; while (*p != '\0'){ if (*p < 0x80){ p++; continue; /* ignore 1 byte char */ } Ccode = ToJIS(p); if ((vfdata = VF_GetOutline(Ccode, Fd)) == NULL){ printf("Failed to get outline : %04x\n", Ccode); exit(-1); } else { VFTable[i++] = vfdata; } p = p + 2; } VFTable[i++] = NULL; /*** START MEASURING ***/ times(&t_start); Repeat = 10; while (Repeat > 0){ for (i = 0; VFTable[i] != NULL; i++){ bzero(Buff, XBytes*YDots); #ifndef USE_SONY_FONT VF_DrawOutline(vfdata, Fd, XDots, YDots, XBytes, 0, Buff); #else if (UseFSlib == 0){ VF_DrawOutline(vfdata, Fd, XDots, YDots, XBytes, 0, Buff); } else { FS_scan_conv(&vfdata[2], XDots, YDots, XBytes, 0, Buff, 0, 0, 0); } #endif } --Repeat; } /*** END MEASURING ***/ times(&t_end); /*** Release Outline Data ***/ for (i = 0; VFTable[i] != NULL; i++){ VF_FreeOutline(VFTable[i], Fd); } VF_CloseFont(Fd); VF_Deinit(); /*** Show performance ***/ printf("FONT ENTRY: %s\n", Ent); printf("Comment: %s \n", Comment); printf("Size: X=%d Y=%d\n", XDots, YDots); printf("USR TIME: %.3f SEC\n", (float) (t_end.tms_utime - t_start.tms_utime) / 60.0); printf("SYS TIME: %.3f SEC\n\n", (float) (t_end.tms_stime - t_start.tms_stime) / 60.0); return 0; } #define etoj(c1, c2) {(c1) &= 0x7f; (c2) &= 0x7f;} #define iseuc1st(c) ((c) >= 0xa1 && (c) <= 0xfe) #define stoe(c1, c2) \ {\ if (c1 >=0xe0)\ c1 -= 0x40;\ if (c2 >= 0x9f) {\ c1 = (c1 - 0x88) * 2 + 0xb0;\ c2 += 0x02;\ } else {\ if (c2 >= 0x7f)\ c2 -= 0x01;\ c1 = (c1 - 0x89) * 2 + 0xb1;\ c2 = c2 + 0x61;\ }\ } #define issjis1st(c) (((c) >= 0x81 && (c) <= 0x9f) || \ ((c) >= 0xe0 && (c) <= 0xfc)) int ToJIS(unsigned char *s) { int j1, j2; j1 = s[0]; j2 = s[1]; #ifdef EUC etoj(j1, j2); #endif #ifdef SJIS stoe(j1, j2); etoj(j1, j2); #endif return (j1*0x100 + j2); }