aboutsummaryrefslogtreecommitdiffstats
pre { line-height: 125%; } td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/* $Id$
 * $URL$
 *
 * thread handling (mutex, shmem, ...)
 *
 * Copyright (C) 2004 Michael Reinelt <reinelt@eunet.at>
 * Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
 *
 * parts of this code are based on the old XWindow driver which is
 * Copyright (C) 2000 Herbert Rosmanith <herp@wildsau.idv.uni-linz.ac.at>
 *
 * This file is part of LCD4Linux.
AgeCommit message (Expand)AuthorFilesLines
2003-07-21[lcd4linux @ 2003-07-21 05:56:48 by reinelt]reinelt1-0/+2
2003-07-19[lcd4linux @ 2003-07-19 09:42:42 by reinelt]reinelt4-7/+177
2003-07-18[lcd4linux @ 2003-07-18 04:43:14 by reinelt]reinelt1-5/+4
2003-06-26[lcd4linux @ 2003-06-26 05:31:16 by reinelt]reinelt1-3/+6
2003-06-22[lcd4linux @ 2003-06-22 19:31:24 by reinelt]reinelt2-0/+128
2003-06-21[lcd4linux @ 2003-06-21 05:46:18 by reinelt]reinelt6-12/+60
2003-06-13[lcd4linux @ 2003-06-13 06:35:56 by reinelt]reinelt1-22/+100
2003-06-13[lcd4linux @ 2003-06-13 05:11:10 by reinelt]reinelt3-7/+16
2003-05-19[lcd4linux @ 2003-05-19 05:55:17 by reinelt]reinelt1-2/+5
2003-05-14[lcd4linux @ 2003-05-14 06:17:39 by reinelt]reinelt1-21/+63
2003-04-12[lcd4linux @ 2003-04-12 16:23:10 by reinelt]reinelt1-2/+6
2003-04-07[lcd4linux @ 2003-04-07 06:02:58 by reinelt]reinelt6-221/+245
2003-04-04[lcd4linux @ 2003-04-04 06:01:59 by reinelt]reinelt8-375/+516
2003-02-27[lcd4linux @ 2003-02-27 07:48:57 by reinelt]reinelt2-12/+12
2003-02-27[lcd4linux @ 2003-02-27 07:43:10 by reinelt]reinelt11-750/+2247
2003-02-24[lcd4linux @ 2003-02-24 04:50:57 by reinelt]reinelt1-25/+65
2003-02-22[lcd4linux @ 2003-02-22 07:53:09 by reinelt]reinelt23-97/+166
2003-02-22[lcd4linux @ 2003-02-22 07:23:24 by reinelt]reinelt1-88/+102
2003-02-18[lcd4linux @ 2003-02-18 06:13:44 by reinelt]reinelt2-329/+327
2003-02-17[lcd4linux @ 2003-02-17 06:06:12 by reinelt]reinelt1-1/+10
2003-02-17[lcd4linux @ 2003-02-17 04:27:58 by reinelt]reinelt13-8/+17
2002-08-19[lcd4linux @ 2002-08-19 07:36:29 by reinelt]reinelt7-359/+481
2002-08-19[lcd4linux @ 2002-08-19 04:41:20 by reinelt]reinelt20-32/+166
2002-08-18[lcd4linux @ 2002-08-18 08:11:11 by reinelt]reinelt1-26/+28
2002-08-17[lcd4linux @ 2002-08-17 14:14:21 by reinelt]reinelt3-67/+101
2002-08-17[lcd4linux @ 2002-08-17 13:10:22 by reinelt]reinelt9-182/+765
2002-08-17[lcd4linux @ 2002-08-17 12:54:08 by reinelt]reinelt1-7/+23
2002-04-30[lcd4linux @ 2002-04-30 07:20:15 by reinelt]reinelt2-173/+129
2002-04-29[lcd4linux @ 2002-04-29 11:00:25 by reinelt]reinelt14-2339/+5100
2001-09-14[lcd4linux @ 2001-09-14 05:57:06 by reinelt]reinelt1-1/+5
2001-09-13[lcd4linux @ 2001-09-13 07:40:57 by reinelt]reinelt1-0/+6
t thread_argc; char **thread_argv; /* glibc 2.1 requires defining semun ourselves */ #ifdef _SEM_SEMUN_UNDEFINED union semun { int val; struct semid_ds *buf; unsigned short int *array; struct seminfo *__buf; }; #endif int mutex_create(void) { int semid; union semun semun; semid = semget(IPC_PRIVATE, 1, 0); if (semid == -1) { error("fatal error: semget() failed: %s", strerror(errno)); return -1; } semun.val = 1; semctl(semid, 0, SETVAL, semun); return semid; } void mutex_lock(const int semid) { struct sembuf sembuf; sembuf.sem_num = 0; sembuf.sem_op = -1; sembuf.sem_flg = 0; semop(semid, &sembuf, 1); } void mutex_unlock(const int semid) { struct sembuf sembuf; sembuf.sem_num = 0; sembuf.sem_op = 1; sembuf.sem_flg = 0; semop(semid, &sembuf, 1); } void mutex_destroy(const int semid) { union semun arg; semctl(semid, 0, IPC_RMID, arg); } int shm_create(void **buffer, const int size) { int shmid; shmid = shmget(IPC_PRIVATE, size, SHM_R | SHM_W); if (shmid == -1) { error("fatal error: shmget() failed: %s", strerror(errno)); return -1; } *buffer = shmat(shmid, NULL, 0); if (*buffer == NULL) { error("fatal error: shmat() failed: %s", strerror(errno)); return -1; } return shmid; } void shm_destroy(const int shmid, const void *buffer) { shmdt(buffer); shmctl(shmid, IPC_RMID, NULL); } int thread_create(const char *name, void (*thread) (void *data), void *data) { pid_t pid, ppid; ppid = getpid(); switch (pid = fork()) { case -1: error("fatal error: fork(%s) failed: %s", name, strerror(errno)); return -1; case 0: info("thread %s starting...", name); if (thread_argc > 0) { strncpy(thread_argv[0], name, strlen(thread_argv[0])); } thread(data); info("thread %s ended.", name); exit(0); default: info("forked process %d for thread %s", pid, name); } return pid; } int thread_destroy(const int pid) { return kill(pid, SIGKILL); }