<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="http://rss.egloos.com/style/blog.xsl" type="text/xsl" media="screen"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
	<title>My life in the world</title>
	<link>http://onredmusic.egloos.com</link>
	<description>Good Life~!</description>
	<language>ko</language>
	<pubDate>Thu, 21 May 2009 12:41:26 GMT</pubDate>
	<generator>Egloos</generator>
	<image>
		<title>My life in the world</title>
		<url>http://pds4.egloos.com/logo/200708/31/87/e0061187.jpg</url>
		<link>http://onredmusic.egloos.com</link>
		<width>80</width>
		<height>106</height>
		<description>Good Life~!</description>
	</image>
  	<item>
		<title><![CDATA[ 구글사, 웹 3D 분야로 진출  ]]> </title>
		<link>http://onredmusic.egloos.com/2386625</link>
		<guid>http://onredmusic.egloos.com/2386625</guid>
		<description>
			<![CDATA[ 
  <p style="TEXT-ALIGN: left"><img class="tx-daum-image" style="CLEAR: none; FLOAT: none; CURSOR: pointer" hspace="1" src="http://cfile219.uf.daum.net/image/1344AB1949F78AF7140459" width="240" vspace="1" border="0" isset="true" actualwidth="240"></p><p style="TEXT-ALIGN: left"><br></p><p>구글사는 검색엔진에 이어 웹 3D 부분의 선두주자가 되려 하고 있다. 최근 웹 브라우저에서 작동 시킬 수 있는 3D 그래픽 어플리케이션을 만들 수 있는 오픈소스 자바 스크립트 API인&nbsp;<a style="BORDER-BOTTOM: rgb(132,0,0) 1px dashed; TEXT-DECORATION: none" onclick="javascript:pageTracker._trackPageview('/outbound/article/code.google.com');" href="http://code.google.com/apis/o3d/" target="_blank" modo="false">O3D</a>를 공개하였다. 구글의&nbsp;<a style="BORDER-BOTTOM: rgb(132,0,0) 1px dashed; TEXT-DECORATION: none" onclick="javascript:pageTracker._trackPageview('/outbound/article/code.google.com');" href="http://code.google.com/" target="_blank" modo="false">Code Labs</a>은 개발자 그룹과의 협업 및 피드박을 받는 그룹이다. O3D는 윈도우와 맥, 그리고 리눅스에서 사용할 수 있다.</p><p>&nbsp;&nbsp; 현재 API를 이용하여 다른 소프트웨어에서 만들어진 3D 형태나 건물의 모습을 COLLADA 포맷에서 작동할 수 있도록 한다. 현재&nbsp;Autodesk 3D Studio Max, Autodesk Maya, Google SketchUp과 기타 일부 CAD 시스템들로부터 이 포맷으로의 export를 할 수 있다.</p><p><br></p><p>흥미로운 전개이다. 웹 브라우저에서 어떠한 CAD 소프트웨어로 작성하여도 호환적으로 즐길 수 있는 시대가 열리고 있다.&nbsp;</p>			 ]]> 
		</description>

		<comments>http://onredmusic.egloos.com/2386625#comments</comments>
		<pubDate>Thu, 21 May 2009 12:41:26 GMT</pubDate>
		<dc:creator>OnRedMusic</dc:creator>
	</item>
	<item>
		<title><![CDATA[ SRS WOW HD & Custom EQ ]]> </title>
		<link>http://onredmusic.egloos.com/2369980</link>
		<guid>http://onredmusic.egloos.com/2369980</guid>
		<description>
			<![CDATA[ 
  <p><strong><span style="COLOR: #ff0000">SRS WOW HD,,,</span></strong></p><p>&nbsp;</p><p><strong><span style="FONT-SIZE: 100%; COLOR: #426bdf">SRS</span></strong><br>Sound Retrieval System의 약자로 디지털 음원의 녹음 혹은 압축시 손실된 음을 원음의 수준으로 복원시켜준다. </p><p>가장 대표적인 3차원 입체 음향 기술로서 Time delay나 Phase shift기술을 사용하지 않아 장시간 음악 감상을 할 때에도 </p><p>피로감을 주지 않는다.</p><p>(너무 올리는 경우 음의 왜곡이 커지고 고사양의 이어폰일 경우에만 높게 설정한다)<br><br><font class="txt_bold2" color="#426bdf" size="2"><strong>TruBass</strong></font><br>음향심리학 (Psychoacoustic) 기술을 기반으로 하여 Bass 성능을 향상시키는 특허 기술. </p><p>가상의 서브우퍼를 구현하여 깊고 풍부한 Bass를 청취자에게 전달한다.<br><br><font class="txt_bold2" color="#426bdf" size="2"><strong>FOCUS</strong></font><br>음향의 이미지 영역을 상승시키고 고주파대역의 명료도를 개선시키는 특허 기술. </p><p>SRS 3D와 조합될 때, FOCUS는 훨씬 크고 넓은 음역을 생성하여, 확대된 음향의 이미지를 전달한다.</p><p>(손실된 음원을 살려준다)</p><p><br><span style="FONT-SIZE: 100%; COLOR: #426bdf"><strong>WOW</strong></span></p><p>음을 수평과 수직으로 확대시켜 공간감을 확장하여 작은 스피커와 헤드폰의 한계를 극복해 준다.</p><p>이 기술을 이용하면 작은 오디오기기,포터블 기기등에서 스피커 크기를 확대하지 않고서도 제품의 오디오 성능을 개선할 수 있다. </p><p>(이어폰,해드폰의 성능에 맞춰 조절한다. 저사양 이어폰등에 너무 높게 설정하면 음의 왜곡이 커진다)<br><br><font class="txt_bold2" color="#426bdf" size="2"><strong>Definition </strong></font><br>보다 생생하고 선명한 사운드를 위한 기술. </p><p>이 기술을 통한 깨끗하고 명료한 사운드는 뮤지컬이나 연극의 보컬, 고주파수 대역의 악기 소리를 들을 수 있게 해주며 </p><p>원본 오디오 음원을 보다 더 세밀하게 들려준다.</p><p>(보컬등 음원을 선명하게 해준다. 이어폰사용시는 최대한 낮게 설정한다. 고주파대역이므로 장시간 청취시 상당한 피로감이 동반될수도 있다)</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p><strong><span style="COLOR: #ff0000">Custom EQ,,,</span></strong></p><p><strong><span style="COLOR: #ff0000"></span></strong>&nbsp;</p><p><strong>50 - 저음<br>200 - 중저음<br>1k - 중음<br>3k - 중고음<br>14k - 고음</strong></p><p><strong></strong>&nbsp;</p><p>Equalizer는 크게 저음,중음,고음 3가지로 나뉜다.</p><p>&nbsp;</p><p><strong>1. 저음</strong></p><p>&nbsp;&nbsp;&nbsp; 저음부 와 같은경우는 Bass 라고도 하며. 저음이 강조되게되면 음악의 무게가 향상되고</p><p>&nbsp;&nbsp;&nbsp; 비트있는 음악은 더욱 리드미클하게, 발라드 나 뉴에이지 계열등의 음악은 더욱 부드럽게 하고,</p><p>&nbsp;&nbsp;&nbsp; 클래식 계열의 음악과 같은경우는 웅장함을 높여주게된다.</p><p>&nbsp;&nbsp;&nbsp; 소리 자체의 압력이 강하기 때문에 EQ를 너무 높이 조절하지 않는다.</p><p>&nbsp;</p><p><strong>2. 중저음,중음</strong></p><p>&nbsp;&nbsp;&nbsp; 저음부분보다는 가볍지만 되도록 저음부분의 악기를 강조하려고 노력하며</p><p>&nbsp;&nbsp;&nbsp; 중저음 부분을 보자면 드럼중에 작은북 (Snare :스네어) 부분과 탐(Tom) 부분을 강조시키는 역할을 한다.</p><p>&nbsp;&nbsp;&nbsp; 중음부가 높아지게되면 소리에 마치&nbsp;파도가 치는듯한&nbsp;약간 거슬리는 소리가 들리게 되고,</p><p>&nbsp;&nbsp;&nbsp; 중음부가 낮아지게되면 마치 비(鼻)음이 섞인듯한 느낌의 소리가 들리게 된다.</p><p>&nbsp;</p><p><strong>3. 중고음,고음</strong></p><p>&nbsp;&nbsp;&nbsp; 중고음의 경우 보컬을 부각시켜 준다.</p><p>&nbsp;&nbsp;&nbsp; 이 부분과 중음부 에서 조절을 어떤식으로 해주느냐에 따라서 보컬이 답답한지 아니면</p><p>&nbsp;&nbsp;&nbsp; 시원한지를 결정 할만큼 보컬에겐 특별한 구간이라 볼수 있다.</p><p>&nbsp;&nbsp;&nbsp; 기타와 같은 악기일경우도 마찬가지로 소리가 막히거나 뚫린느낌을 확연하게 느낄수가 있다.</p><p>&nbsp;&nbsp;&nbsp; 대신 중음부가 낮아질수록 중음을 강조하는 악기 소리는 점점 들리지 않게 된다.</p><p>&nbsp;&nbsp;&nbsp; 이를 주의해서 조절한다.&nbsp;&nbsp;</p><p>&nbsp;&nbsp;&nbsp; 다른 EQ를 모두 줄이고 고음부를 부각시키면 소리의 날카로움을 얻을수 있지만</p><p>&nbsp;&nbsp;&nbsp; 고음부가 낮으면 답답하고 맹한 소리가 된다. <div class="autosourcing-stub"><p style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 0px; MARGIN: 11px 0px 7px; PADDING-TOP: 0px; FONT-STYLE: normal; FONT-FAMILY: Dotum"><strong style="PADDING-RIGHT: 7px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">[출처]</strong> <a href="http://blog.naver.com/pooh681226/40047900368" target="_blank">srs wow HD와 Custom EQ설정.</a><span style="PADDING-RIGHT: 7px; PADDING-LEFT: 5px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">|</span><strong style="PADDING-RIGHT: 7px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">작성자</strong> <a href="http://blog.naver.com/pooh681226" target="_blank">덥칠이</a></p></div><p></p>			 ]]> 
		</description>

		<comments>http://onredmusic.egloos.com/2369980#comments</comments>
		<pubDate>Tue, 05 May 2009 05:02:19 GMT</pubDate>
		<dc:creator>OnRedMusic</dc:creator>
	</item>
	<item>
		<title><![CDATA[ 서블릿 쿠키에 한글값 넣기 ]]> </title>
		<link>http://onredmusic.egloos.com/2031047</link>
		<guid>http://onredmusic.egloos.com/2031047</guid>
		<description>
			<![CDATA[ 
  <a href="http://cafe.naver.com/webprogrammer2.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=74">http://cafe.naver.com/webprogrammer2.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=74</a>			 ]]> 
		</description>
		<category>Site Link</category>

		<comments>http://onredmusic.egloos.com/2031047#comments</comments>
		<pubDate>Wed, 17 Sep 2008 16:03:36 GMT</pubDate>
		<dc:creator>OnRedMusic</dc:creator>
	</item>
	<item>
		<title><![CDATA[ Dev-C++ ]]> </title>
		<link>http://onredmusic.egloos.com/2008868</link>
		<guid>http://onredmusic.egloos.com/2008868</guid>
		<description>
			<![CDATA[ 
  데블 씨쁠 사이트<br><a href="http://www.bloodshed.net/dev/devcpp.html">http://www.bloodshed.net/dev/devcpp.html</a>			 ]]> 
		</description>
		<category>Site Link</category>

		<comments>http://onredmusic.egloos.com/2008868#comments</comments>
		<pubDate>Mon, 08 Sep 2008 02:03:02 GMT</pubDate>
		<dc:creator>OnRedMusic</dc:creator>
	</item>
	<item>
		<title><![CDATA[ Oracle SQL문(예제) ]]> </title>
		<link>http://onredmusic.egloos.com/1909083</link>
		<guid>http://onredmusic.egloos.com/1909083</guid>
		<description>
			<![CDATA[ 
  <p>1<br>1. emp 테이블에서 job이 'MANAGER'이고 HIREDATE(입사일)이&nbsp; 1981년 5월이후인 사람의 모든 항목(칼럼)을 검색하세요.<br>SELECT * FROM EMP<br>WHERE JOB = 'MANAGER'<br>AND HIREDATE &gt;= '81/05/01';<br></p><p>2.사원이름에 'N'이 들어가는 모든 사람을 검색하세요.<br>SELECT * FROM EMP<br>WHERE ENAME LIKE '%N%';</p><p><br>3.부서번호가 20번이거나 30번 사람중 JOB이 SALESMAN 인 사람을 검색하세요.<br>SELECT * FROM EMP<br>WHERE JOB = 'SALESMAN'<br>AND DEPTNO IN (20, 30);</p><p>4.사원번호가 7600번 이상이고, 월급이 2000 이상인 사람을 검색하세요.<br>SELECT * FROM EMP<br>WHERE EMPNO&gt;=7600<br>AND SAL&gt;=2000;</p><p><br>5.사원이름이 KING 인 사람의 JOB과 입사일을 검색하세요.<br>SELECT JOB, HIREDATE FROM EMP<br>WHERE ENAME = 'KING';</p><p><br>6.JOB이 SALESMAN이고 COMM이 널이 아닌 사원의 이름과 부서번호(DEPTNO)를 검색하세요.<br>SELECT ENAME, DEPTNO FROM EMP<br>WHERE JOB = 'SALESMAN'<br>AND COMM IS NOT NULL;<br>&nbsp;<br>7.사원의 이름을 내림차순 정렬하세요.<br>SELECT ENAME FROM EMP<br>ORDER BY ENAME DESC;</p><p><br>8,1981년 1월 1일 이후에 입사한 사원의 이름과 JOB을 검색하세요.<br>SELECT ENAME, JOB FROM EMP<br>WHERE HIREDATE &gt;='81/01/01';</p><p>2<br>1. 임금의 평균을 구하되 소숫점 이하 자리는 버리세요.<br>SELECT TRUNC(AVG(SAL),0) "AVG"<br>FROM EMP;</p><p><br>2 월급이 가장 많은 월급과&nbsp; 가장 적은 월급. 그리고 월급 차를 구하세요.</p><p>SELECT MAX(SAL) AS MAX MIN(SAL) AS MIN MAX(SAL)-MIN(SAL) AS "MINUS" MINUS<br>FROM EMP;</p><p><br>3.직업(JOB)별로 월급(SAL)의 평균을 구하세요.</p><p>SELECT JOB, AVG(SAL)<br>FROM EMP<br>GROUP BY JOB;</p><p><br>4.부서(DEPTNO)별로 임금 (SAL)의 합계를 구하되 합계가 10,000 이상인 <br>부서의 부서와 합계를 구하세요.</p><p>SELECT DEPTNO, SUM(SAL)<br>FROM EMP<br>GROUP BY DEPTNO<br>HAVING SUM(SAL) &gt;=10000;</p><p><br>3<br>사원들의 이름,부서번호,부서이름 출력<br>SELECT EMP.ENAME, EMP.DEPTNO, DEPT.DNAME<br>FROM EMP, DEPT<br>WHERE EMP.DEPTNO = DEPT.DEPTNO;</p><p><br>부서번호가 30번인 사원들의 이름,직급,부서번호,부서위치 출력<br>SELECT EMP.ENAME, EMP.JOB, DEPT.DEPTNO, DEPT.LOC<br>FROM EMP, DEPT<br>WHERE EMP.DEPTNO = DEPT.DEPTNO<br>AND DEPT.DEPTNO = 30;<br>&nbsp;<br>커미션을 받는 사원의 이름,커미션,부서이름 및 부서위치를 출력<br>SELECT EMP.ENAME, EMP.COMM, DEPT.DNAME, DEPT.LOC<br>FROM EMP, DEPT<br>WHERE EMP.DEPTNO = DEPT.DEPTNO<br>AND EMP.COMM IS NOT NULL AND EMP.COMM NOT IN(0);</p><p><br>'DALLAS'에서 근무하는 사원의 이름,직급, 부서번호,부서이름<br>SELECT EMP.ENAME, EMP.JOB, DEPT.DEPTNO, DEPT.DNAME<br>FROM EMP, DEPT<br>WHERE EMP.DEPTNO=DEPT.DEPTNO<br>AND DEPT.LOC = 'DALLAS';</p><p><br>이름에 A가 들어가는 사원들의 이름과 부서이름<br>SELECT EMP.ENAME, DEPT.DNAME<br>FROM EMP, DEPT<br>WHERE EMP.DEPTNO = DEPT.DEPTNO<br>AND EMP.ENAME LIKE '%A%';</p><p><br>사원이름과 직급,급여,급여등급 <br>SELECT EMP.ENAME, EMP.JOB, EMP.SAL, SALGRADE.GRADE<br>FROM EMP, SALGRADE<br>WHERE EMP.SAL BETWEEN SALGRADE.LOSAL AND SALGRADE.HISAL;</p><p>//<br>SELECT E.ENAME, E.JOB,E.SAL, S.GRADE<br>FROM EMP E, SALGRADE S<br>WHERE E.SAL &gt;= S.LOSAL AND E.SAL &lt;= S.HISAL<br><br>사원이름, 부서번호와 해당 사원과 같은 부서에서 근무하는 사원<br>SELECT EMP.ENAME, EMP.DEPTNO, DEPT.DNAME<br>FROM EMP, DEPT<br>WHERE EMP.DEPTNO = DEPT.DEPTNO<br>ORDER BY DEPT.DNAME;<br>(SELF JOIN)</p><p>//<br>select a.ename,a.deptno,b.ename,b.deptno<br>from emp a,EMP b<br>where a.deptno = b.deptno<br>ORDER BY A.Ename;</p><p>4<br>2.사원이름과,급여,입사일을 검색하세요.<br>SELECT DNAME, SAL, HIREDATE FROM EMP;</p><p><br>3.부서 번호를 한 번씩만 출력되도록 검색하세요.<br>SELECT DISTINCT DEPTNO FROM DEPT;</p><p><br>4.라인사이지즈를 120으로 세팅하세요.<br>SET LINESIZE 120;</p><p><br>5."FORD"의 사원 번호와, 이름, 부서번호를 검색하세요.<br>SELECT EMPNO, ENAME, DEPTNO FROM EMP WHERE ENAME = 'FORD';</p><p><br>6.이름에 "S"가 들어가는 사원의 사원 번호와 이름,부서번호를 검색하세요.<br>SELECT EMPNO, ENAME, DEPTNO FROM EMP WHERE ENAME LIKE '%S%';</p><p><br>7.이름에 "R"이 들어가고 급여가 3000이상인 사람의 이름과,직급을 검색하세요<br>SELECT ENAME, JOB, SAL<br>FROM EMP<br>WHERE ENAME LIKE '%R%'<br>AND SAL &gt;=3000; </p><p><br>8.'XXXI LOVE YOUXXX' 에서 'X'를 삭제하고 출력하세요.<br>SELECT TRIM('X' FROM 'XXXI LOVE YOUXXX')<br>FROM DUAL</p><p><br>9.사원별로 이름과,직급,연봉(급여에 커미션을 더한 값)을 검색하세요.<br>SELECT ENAME, JOB, SAL*12+NVL(COMM,0)<br>FROM EMP</p><p><br>10. EMP 테이블의 행의 갯수를 검색하세요.<br>SELECT COUNT(*)<br>FROM EMP</p><p><br>11.부서 번호와 부서별 연봉 평균을 구하세요.<br>SELECT DEPTNO, AVG(SAL)<br>FROM EMP<br>GROUP BY DEPTNO</p><p><br>12.부서번호가 20번인 사원들의 이름, 직급, 부서번호, 부서위치(지역)을 검색하세요.<br>SELECT E.ENAME, E.JOB, D.LOC, E.DEPTNO<br>FROM EMP E, DEPT D<br>WHERE E.DEPTNO = D.DEPTNO<br>AND E.DEPTNO=20</p><p><br>13. 직급이 'ANALYST' 인 사람의 부서번호, 부서이름, 지역을 출력하세요.<br>SELECT E.JOB, D.DEPTNO, D.DNAME,D. LOC<br>FROM EMP E, DEPT D<br>WHERE E.DEPTNO = D.DEPTNO<br>AND JOB='ANALYST'</p>			 ]]> 
		</description>
		<category>IT &amp; news</category>

		<comments>http://onredmusic.egloos.com/1909083#comments</comments>
		<pubDate>Wed, 30 Jul 2008 01:42:48 GMT</pubDate>
		<dc:creator>OnRedMusic</dc:creator>
	</item>
	<item>
		<title><![CDATA[ Dining-Philosophers Problem ]]> </title>
		<link>http://onredmusic.egloos.com/1735264</link>
		<guid>http://onredmusic.egloos.com/1735264</guid>
		<description>
			<![CDATA[ 
  <p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%; TEXT-DECORATION: underline">/*&nbsp; pthread_create.c&nbsp;&nbsp;&nbsp; </span><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%">*/</span></p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold"><br></span></p><p class="HStyle0">#include &lt;stdio.h&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* standard I/O routines&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */</p><p class="HStyle0">#include &lt;pthread.h&gt;&nbsp;&nbsp;&nbsp;&nbsp; /* pthread functions and data structures */</p><p class="HStyle0"><br></p><p class="HStyle0">/* function to be executed by the new thread */</p><p class="HStyle0">void*&nbsp; do_loop(void* data)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;int i;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* counter, to print numbers */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;int j;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* counter, for delay&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;int me = *((int*)data);&nbsp;&nbsp;&nbsp;&nbsp; /* thread identifying number */</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;for (i=0; i&lt;10; i++) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (j=0; j&lt;500000; j++) /* delay loop */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("'%d' - Got '%d'\n", me, i);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;}</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;/* terminate the thread */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_exit(NULL);</p><p class="HStyle0">}</p><p class="HStyle0"><br></p><p class="HStyle0">/* like any C program, program's execution begins in main */</p><p class="HStyle0">main(int argc, char* argv[])</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; thr_id;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* thread ID for the newly created thread */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_t&nbsp; p_thread;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* thread's structure&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 1;&nbsp; /* thread 1 identifying number&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 2;&nbsp; /* thread 2 identifying number&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;/* create a new thread that will execute 'do_loop()' */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;thr_id = pthread_create(&amp;p_thread, NULL, do_loop, (void*)&amp;a);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;/* run 'do_loop()' in the main thread as well */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;do_loop((void*)&amp;b);</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;/* NOT REACHED */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;return 0;</p><p class="HStyle0">}</p><p class="HStyle0" style="LINE-HEIGHT: 120%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="FONT-WEIGHT: bold; FONT-SIZE: 15pt; LINE-HEIGHT: 120%">&nbsp;Dining Philosophers Problem</span></p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 15pt; LINE-HEIGHT: 120%"><br></span></p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 120%"><br></span></p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 120%; TEXT-DECORATION: underline">/*&nbsp; dphil.h&nbsp;&nbsp;&nbsp; </span><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 120%">*/</span></p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%"><br></span></p><p class="HStyle0">typedef struct {</p><p class="HStyle0">int id;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* The philosopher's id: 0 to 5 */</p><p class="HStyle0">long t0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* The time when the program started */</p><p class="HStyle0">long ms;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* The maximum time that philosopher sleeps/eats */</p><p class="HStyle0">void *v;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* The void * that you&nbsp; define */</p><p class="HStyle0">int *blocktime;&nbsp;&nbsp; /* Total time that a philosopher is blocked */</p><p class="HStyle0">int *blockstarting;&nbsp; /* If a philosopher is currently blocked, the time that he</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;started blocking */</p><p class="HStyle0">int phil_count;</p><p class="HStyle0">pthread_mutex_t *blockmon; /* monitor for blocktime */</p><p class="HStyle0">} Phil_struct;</p><p class="HStyle0"><br></p><p class="HStyle0">extern void *initialize_v(int phil_count);</p><p class="HStyle0">extern void pickup(Phil_struct *);</p><p class="HStyle0">extern void putdown(Phil_struct *);</p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%"><br></span></p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%"><br></span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">/*</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;* </span><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%; TEXT-DECORATION: underline">dphil_skeleton.c -- Dining philosophers driver program</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;*/</span></p><p class="HStyle0"><br></p><p class="HStyle0"><br></p><p class="HStyle0">#include &lt;stdio.h&gt;</p><p class="HStyle0">#include &lt;pthread.h&gt;</p><p class="HStyle0">#include "dphil.h"</p><p class="HStyle0"><br></p><p class="HStyle0"><br></p><p class="HStyle0">void *philosopher(void *v)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Phil_struct *ps;</p><p class="HStyle0">&nbsp;&nbsp;long st;</p><p class="HStyle0">&nbsp;&nbsp;long t;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;ps = (Phil_struct *) v;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;while(1) {</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;/* First the philosopher thinks for a random number of seconds */</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;st = (random()%ps-&gt;ms) + 1;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;printf("%3d Philosopher %d thinking for %d second%s\n",</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;time(0)-ps-&gt;t0, ps-&gt;id, st, (st == 1) ? "" : "s");</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;fflush(stdout);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;sleep(st);</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;/* Now, the philosopher wakes up and wants to eat.&nbsp; He calls pickup</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to pick up the chopsticks */</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;printf("%3d Philosopher %d no longer thinking -- calling pickup()\n",</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;time(0)-ps-&gt;t0, ps-&gt;id);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;fflush(stdout);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;t = time(0);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_lock(ps-&gt;blockmon);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;ps-&gt;blockstarting[ps-&gt;id] = t;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_unlock(ps-&gt;blockmon);</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pickup(ps);</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_lock(ps-&gt;blockmon);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;ps-&gt;blocktime[ps-&gt;id] += (time(0) - t);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;ps-&gt;blockstarting[ps-&gt;id] = -1;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_unlock(ps-&gt;blockmon);</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;/* When pickup returns, the philosopher can eat for a random number of</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;seconds */</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;st = (random()%ps-&gt;ms) + 1;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;printf("%3d Philosopher %d eating for %d second%s\n",</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;time(0)-ps-&gt;t0, ps-&gt;id, st, (st == 1) ? "" : "s");</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;fflush(stdout);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;sleep(st);</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;/* Finally, the philosopher is done eating, and calls putdown to</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;put down the chopsticks */</p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%"><br></span></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;printf("%3d Philosopher %d no longer eating -- calling putdown()\n",</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;time(0)-ps-&gt;t0, ps-&gt;id);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;fflush(stdout);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;putdown(ps);</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0">}</p><p class="HStyle0"><br></p><p class="HStyle0">main(argc, argv)</p><p class="HStyle0">int argc;</p><p class="HStyle0">char **argv;</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;int i;</p><p class="HStyle0">&nbsp;&nbsp;pthread_t *threads;</p><p class="HStyle0">&nbsp;&nbsp;Phil_struct *ps;</p><p class="HStyle0">&nbsp;&nbsp;void *v;</p><p class="HStyle0">&nbsp;&nbsp;long t0, ttmp, ttmp2;</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_t *blockmon;</p><p class="HStyle0">&nbsp;&nbsp;int *blocktime;</p><p class="HStyle0">&nbsp;&nbsp;int *blockstarting;</p><p class="HStyle0">&nbsp;&nbsp;char s[500];</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0">&nbsp;&nbsp;char *curr;</p><p class="HStyle0">&nbsp;&nbsp;int total;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;if (argc != 3) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr, "usage: dphil philosopher_count maxsleepsec\n");</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;exit(1);</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;srandom(time(0));</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;phil_count = atoi(argv[1]);</p><p class="HStyle0">&nbsp;&nbsp;threads = (pthread_t *) malloc(sizeof(pthread_t)*phil_count);</p><p class="HStyle0">&nbsp;&nbsp;if (threads == NULL) { perror("malloc"); exit(1); }</p><p class="HStyle0">&nbsp;&nbsp;ps = (Phil_struct *) malloc(sizeof(Phil_struct)*phil_count);</p><p class="HStyle0">&nbsp;&nbsp;if (ps == NULL) { perror("malloc"); exit(1); }</p><p class="HStyle0"><br></p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;v = initialize_v(phil_count);</p><p class="HStyle0">&nbsp;&nbsp;t0 = time(0);</p><p class="HStyle0">&nbsp;&nbsp;blocktime = (int *) malloc(sizeof(int)*phil_count);</p><p class="HStyle0">&nbsp;&nbsp;if (blocktime == NULL) { perror("malloc blocktime"); exit(1); }</p><p class="HStyle0">&nbsp;&nbsp;blockstarting = (int *) malloc(sizeof(int)*phil_count);</p><p class="HStyle0">&nbsp;&nbsp;if (blockstarting == NULL) { perror("malloc blockstarting"); exit(1); }</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;blockmon = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_init(blockmon, NULL);</p><p class="HStyle0">&nbsp;&nbsp;for (i = 0; i &lt; phil_count; i++) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;blocktime[i] = 0;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;blockstarting[i] = -1;</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;for (i = 0; i &lt; phil_count; i++) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;ps[i].id = i;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;ps[i].t0 = t0;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;ps[i].v = v;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;ps[i].ms = atoi(argv[2]);</p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%">&nbsp;&nbsp; </span>ps[i].blocktime = blocktime;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;ps[i].blockstarting = blockstarting;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;ps[i].blockmon = blockmon;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;ps[i].phil_count = phil_count;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_create(threads+i, NULL, philosopher, (void *) (ps+i));</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;while(1) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_lock(blockmon);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;ttmp = time(0);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;curr = s;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;total = 0;</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;for(i=0; i &lt; phil_count; i++) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total += blocktime[i];</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (blockstarting[i] != -1) total += (ttmp - blockstarting[i]);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;}</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;sprintf(curr,"%3d Total blocktime: %5d : ", ttmp-t0, total);</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;curr = s + strlen(s);</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;for(i=0; i &lt; phil_count; i++) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ttmp2 = blocktime[i];</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (blockstarting[i] != -1) ttmp2 += (ttmp - blockstarting[i]);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sprintf(curr, "%5d ", ttmp2);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;curr = s + strlen(s);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;}</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_unlock(blockmon);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;printf("%s\n", s);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;fflush(stdout);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;sleep(10);</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0">}</p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%"><br></span></p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%">/*&nbsp;&nbsp; dphil_1.c&nbsp;&nbsp; </span></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 160%">-- Dining philosophers solution #1 -- the null solution */</span></p><p class="HStyle0"><br></p><p class="HStyle0">#include &lt;stdio.h&gt;</p><p class="HStyle0">#include &lt;pthread.h&gt;</p><p class="HStyle0">#include "dphil.h"</p><p class="HStyle0"><br></p><p class="HStyle0">void pickup(Phil_struct *ps)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;return;</p><p class="HStyle0">}</p><p class="HStyle0"><br></p><p class="HStyle0">void putdown(Phil_struct *ps)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;return;</p><p class="HStyle0">}</p><p class="HStyle0"><br></p><p class="HStyle0">void *initialize_v(int phil_count)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;return NULL;</p><p class="HStyle0">}</p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%"><br></span></p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%"><br></span></p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%">/*&nbsp;&nbsp; </span><span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 120%">dphil_2.c&nbsp;&nbsp; </span></p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; LINE-HEIGHT: 160%">-- Dining philosophers solution #2 --&nbsp; */</span></p><p class="HStyle0" style="LINE-HEIGHT: 120%"><br></p><p class="HStyle0">#include &lt;stdio.h&gt;</p><p class="HStyle0">#include &lt;pthread.h&gt;</p><p class="HStyle0">#include "dphil.h"</p><p class="HStyle0"><br></p><p class="HStyle0"><br></p><p class="HStyle0"><br></p><p class="HStyle0">typedef struct sticks {</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_t **lock;</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0">} Sticks;</p><p class="HStyle0"><br></p><p class="HStyle0"><br></p><p class="HStyle0">void pickup(Phil_struct *ps)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Sticks *pp;</p><p class="HStyle0">&nbsp;&nbsp;int i;</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp = (Sticks *) ps-&gt;v;</p><p class="HStyle0">&nbsp;&nbsp;phil_count = pp-&gt;phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_lock(pp-&gt;lock[ps-&gt;id]);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* lock up left stick */</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_lock(pp-&gt;lock[(ps-&gt;id+1)%phil_count]); /* lock up right stick */</p><p class="HStyle0">}</p><p class="HStyle0"><br></p><p class="HStyle0">void putdown(Phil_struct *ps)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Sticks *pp;</p><p class="HStyle0">&nbsp;&nbsp;int i;</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp = (Sticks *) ps-&gt;v;</p><p class="HStyle0">&nbsp;&nbsp;phil_count = pp-&gt;phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_unlock(pp-&gt;lock[(ps-&gt;id+1)%phil_count]); /* unlock right stick */</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_unlock(pp-&gt;lock[ps-&gt;id]);&nbsp; /* unlock left stick */</p><p class="HStyle0">}</p><p class="HStyle0"><br></p><p class="HStyle0">void *initialize_v(int phil_count)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Sticks *pp;</p><p class="HStyle0">&nbsp;&nbsp;int i;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp = (Sticks *) malloc(sizeof(Sticks));</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp-&gt;phil_count = phil_count;</p><p class="HStyle0">&nbsp;&nbsp;pp-&gt;lock = (pthread_mutex_t **) malloc(sizeof(pthread_mutex_t *)*phil_count);</p><p class="HStyle0">&nbsp;&nbsp;if (pp-&gt;lock == NULL) { perror("malloc"); exit(1); }</p><p class="HStyle0">&nbsp;&nbsp;for (i = 0; i &lt; phil_count; i++) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pp-&gt;lock[i] = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;if (pp-&gt;lock[i] == NULL) { perror("malloc"); exit(1); }</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0">&nbsp;&nbsp;for (i = 0; i &lt; phil_count; i++) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_init(pp-&gt;lock[i], NULL);</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;return (void *) pp;</p><p class="HStyle0">}</p><p class="HStyle0" style="LINE-HEIGHT: 120%"><br></p><p class="HStyle0" style="LINE-HEIGHT: 120%"><br></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">/*</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%"></span><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">dphil_3.c -- Dining philosophers solution #3 -- putting a</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;sleep call in between getting sticks one and two.</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;dphil_3.c is the same as dphil_2.c, bt it puts a 1-second delay&nbsp;&nbsp; between picking up chopstick one and chopstick two.</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;You get deadlock instantly as all the philosophers try to pick up</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;their chopsticks at once</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;*/</span></p><p class="HStyle0"><br></p><p class="HStyle0"><br></p><p class="HStyle0">#include &lt;stdio.h&gt;</p><p class="HStyle0">#include &lt;pthread.h&gt;</p><p class="HStyle0">#include "dphil.h"</p><p class="HStyle0"><br></p><p class="HStyle0">typedef struct sticks {</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_t **lock;</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0">} Sticks;</p><p class="HStyle0"><br></p><p class="HStyle0"><br></p><p class="HStyle0">void pickup(Phil_struct *ps)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Sticks *pp;</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp = (Sticks *) ps-&gt;v;</p><p class="HStyle0">&nbsp;&nbsp;phil_count = pp-&gt;phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_lock(pp-&gt;lock[ps-&gt;id]);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* lock up left stick */</p><p class="HStyle0">&nbsp;&nbsp;sleep(3);</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_lock(pp-&gt;lock[(ps-&gt;id+1)%phil_count]); /* lock up right stick */</p><p class="HStyle0">}</p><p class="HStyle0"><br></p><p class="HStyle0">void putdown(Phil_struct *ps)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Sticks *pp;</p><p class="HStyle0">&nbsp;&nbsp;int i;</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp = (Sticks *) ps-&gt;v;</p><p class="HStyle0">&nbsp;&nbsp;phil_count = pp-&gt;phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_unlock(pp-&gt;lock[(ps-&gt;id+1)%phil_count]); /* unlock right stick */</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_unlock(pp-&gt;lock[ps-&gt;id]);&nbsp; /* unlock left stick */</p><p class="HStyle0">}</p><p class="HStyle0"><br></p><p class="HStyle0">void *initialize_v(int phil_count)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Sticks *pp;</p><p class="HStyle0">&nbsp;&nbsp;int i;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp = (Sticks *) malloc(sizeof(Sticks));</p><p class="HStyle0">&nbsp;&nbsp;pp-&gt;phil_count = phil_count;</p><p class="HStyle0">&nbsp;&nbsp;pp-&gt;lock = (pthread_mutex_t **) malloc(sizeof(pthread_mutex_t *)*phil_count);</p><p class="HStyle0">&nbsp;&nbsp;if (pp-&gt;lock == NULL) { perror("malloc"); exit(1); }</p><p class="HStyle0">&nbsp;&nbsp;for (i = 0; i &lt; phil_count; i++) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pp-&gt;lock[i] = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;if (pp-&gt;lock[i] == NULL) { perror("malloc"); exit(1); }</p><p class="HStyle0">&nbsp;}</p><p class="HStyle0">&nbsp;&nbsp;for (i = 0; i &lt; phil_count; i++) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_init(pp-&gt;lock[i], NULL);</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;return (void *) pp;</p><p class="HStyle0">}</p><p class="HStyle0" style="LINE-HEIGHT: 120%"><br></p><p class="HStyle0"><br></p><p class="HStyle0"><br></p><p class="HStyle0"><br></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">/*</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;dphil_4.c -- Dining philosophers solution #4 -- an asymmetrical solution.</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;dphil_4.c is the same as dphil_2.c, only odd philosophers start left-hand first, and even</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;philosophers start right-hand first. This does not deadlock, even if you put a delay in</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;between pickup up chopsticks one and two.</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;*/</span></p><p class="HStyle0"><br></p><p class="HStyle0">#include &lt;stdio.h&gt;</p><p class="HStyle0">#include &lt;pthread.h&gt;</p><p class="HStyle0">#include "dphil.h"</p><p class="HStyle0"><br></p><p class="HStyle0">typedef struct sticks {</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_t **lock;</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0">} Sticks;</p><p class="HStyle0"><br></p><p class="HStyle0"><br></p><p class="HStyle0">void pickup(Phil_struct *ps)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Sticks *pp;</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp = (Sticks *) ps-&gt;v;</p><p class="HStyle0">&nbsp;&nbsp;phil_count = pp-&gt;phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;if (ps-&gt;id % 2 == 1) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_lock(pp-&gt;lock[ps-&gt;id]);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* lock up left stick */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_lock(pp-&gt;lock[(ps-&gt;id+1)%phil_count]); /* lock right stick */</p><p class="HStyle0">&nbsp;&nbsp;} else {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_lock(pp-&gt;lock[(ps-&gt;id+1)%phil_count]); /* lock right stick */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_lock(pp-&gt;lock[ps-&gt;id]);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* lock up left stick */</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0">}</p><p class="HStyle0"><br></p><p class="HStyle0">void putdown(Phil_struct *ps)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Sticks *pp;</p><p class="HStyle0">&nbsp;&nbsp;int i;</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp = (Sticks *) ps-&gt;v;</p><p class="HStyle0">&nbsp;&nbsp;phil_count = pp-&gt;phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;if (ps-&gt;id % 2 == 1) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_unlock(pp-&gt;lock[(ps-&gt;id+1)%phil_count]); /* unlock right stick */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_unlock(pp-&gt;lock[ps-&gt;id]);&nbsp; /* unlock left stick */</p><p class="HStyle0">&nbsp;&nbsp;} else {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_unlock(pp-&gt;lock[ps-&gt;id]);&nbsp; /* unlock left stick */</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_unlock(pp-&gt;lock[(ps-&gt;id+1)%phil_count]); /* unlock right stick */</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0">}</p><p class="HStyle0"><br></p><p class="HStyle0">void *initialize_v(int phil_count)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Sticks *pp;</p><p class="HStyle0">&nbsp;&nbsp;int i;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp = (Sticks *) malloc(sizeof(Sticks));</p><p class="HStyle0" style="LINE-HEIGHT: 120%">&nbsp; pp-&gt;phil_count = phil_count;</p><p class="HStyle0">&nbsp;&nbsp;pp-&gt;lock = (pthread_mutex_t **) malloc(sizeof(pthread_mutex_t *)*phil_count);</p><p class="HStyle0">&nbsp;&nbsp;if (pp-&gt;lock == NULL) { perror("malloc"); exit(1); }</p><p class="HStyle0">&nbsp;&nbsp;for (i = 0; i &lt; phil_count; i++) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pp-&gt;lock[i] = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;if (pp-&gt;lock[i] == NULL) { perror("malloc"); exit(1); }</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0">&nbsp;&nbsp;for (i = 0; i &lt; phil_count; i++) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_mutex_init(pp-&gt;lock[i], NULL);</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;return (void *) pp;</p><p class="HStyle0">}</p><p class="HStyle0" style="LINE-HEIGHT: 120%"><br></p><p class="HStyle0" style="LINE-HEIGHT: 120%"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 120%"><br></span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">/*</span></p><p class="HStyle0"><span style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; LINE-HEIGHT: 160%">&nbsp;dphil_5.c -- Dining philosophers solution #5 -- Starvation solution&nbsp; */</span></p><p class="HStyle0"><br></p><p class="HStyle0">#include &lt;stdio.h&gt;</p><p class="HStyle0">#include &lt;pthread.h&gt;</p><p class="HStyle0">#include "dphil.h"</p><p class="HStyle0"><br></p><p class="HStyle0">#define THINKING 0</p><p class="HStyle0">#define HUNGRY 1</p><p class="HStyle0">#define EATING 2</p><p class="HStyle0"><br></p><p class="HStyle0">typedef struct {</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_t *mon;</p><p class="HStyle0">&nbsp;&nbsp;pthread_cond_t **cv;</p><p class="HStyle0">&nbsp;&nbsp;int *state;</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0">} Phil;</p><p class="HStyle0"><br></p><p class="HStyle0"><br></p><p class="HStyle0">void pickup(Phil_struct *ps)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Phil *pp;</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp = (Phil *) ps-&gt;v;</p><p class="HStyle0">&nbsp;&nbsp;phil_count = pp-&gt;phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_lock(pp-&gt;mon);</p><p class="HStyle0">&nbsp;&nbsp;pp-&gt;state[ps-&gt;id] = HUNGRY;</p><p class="HStyle0">&nbsp;&nbsp;while (pp-&gt;state[(ps-&gt;id + (phil_count-1))%phil_count] == EATING ||</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pp-&gt;state[(ps-&gt;id + 1)%phil_count] == EATING) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_cond_wait(pp-&gt;cv[ps-&gt;id], pp-&gt;mon);</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0">&nbsp;&nbsp;pp-&gt;state[ps-&gt;id] = EATING;</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_unlock(pp-&gt;mon);</p><p class="HStyle0">}</p><p class="HStyle0"><br></p><p class="HStyle0">void putdown(Phil_struct *ps)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Phil *pp;</p><p class="HStyle0">&nbsp;&nbsp;int phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp = (Phil *) ps-&gt;v;</p><p class="HStyle0">&nbsp;&nbsp;phil_count = pp-&gt;phil_count;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_lock(pp-&gt;mon);</p><p class="HStyle0">&nbsp;&nbsp;pp-&gt;state[ps-&gt;id] = THINKING;</p><p class="HStyle0">&nbsp;&nbsp;if (pp-&gt;state[(ps-&gt;id+(phil_count-1))%phil_count] == HUNGRY) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_cond_signal(pp-&gt;cv[(ps-&gt;id+(phil_count-1))%phil_count]);</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0">&nbsp;&nbsp;if (pp-&gt;state[(ps-&gt;id+1)%phil_count] == HUNGRY) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_cond_signal(pp-&gt;cv[(ps-&gt;id+1)%phil_count]);</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_unlock(pp-&gt;mon);</p><p class="HStyle0">}</p><p class="HStyle0" style="LINE-HEIGHT: 120%"><br></p><p class="HStyle0">void *initialize_v(int phil_count)</p><p class="HStyle0">{</p><p class="HStyle0">&nbsp;&nbsp;Phil *pp;</p><p class="HStyle0">&nbsp;&nbsp;int i;</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;pp = (Phil *) malloc(sizeof(Phil));</p><p class="HStyle0">&nbsp;&nbsp;pp-&gt;phil_count = phil_count;</p><p class="HStyle0">&nbsp;&nbsp;pp-&gt;mon = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));</p><p class="HStyle0">&nbsp;&nbsp;pp-&gt;cv = (pthread_cond_t **) malloc(sizeof(pthread_cond_t *)*phil_count);</p><p class="HStyle0">&nbsp;&nbsp;if (pp-&gt;cv == NULL) { perror("malloc"); exit(1); }</p><p class="HStyle0">&nbsp;&nbsp;pp-&gt;state = (int *) malloc(sizeof(int)*phil_count);</p><p class="HStyle0">&nbsp;&nbsp;if (pp-&gt;state == NULL) { perror("malloc"); exit(1); }</p><p class="HStyle0">&nbsp;&nbsp;pthread_mutex_init(pp-&gt;mon, NULL);</p><p class="HStyle0">&nbsp;&nbsp;for (i = 0; i &lt; phil_count; i++) {</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pp-&gt;cv[i] = (pthread_cond_t *) malloc(sizeof(pthread_cond_t));</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;if (pp-&gt;cv[i] == NULL) { perror("malloc"); exit(1); }</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pthread_cond_init(pp-&gt;cv[i], NULL);</p><p class="HStyle0">&nbsp;&nbsp;&nbsp;&nbsp;pp-&gt;state[i] = THINKING;</p><p class="HStyle0">&nbsp;&nbsp;}</p><p class="HStyle0"><br></p><p class="HStyle0">&nbsp;&nbsp;return (void *) pp;</p><p class="HStyle0">}</p><div class="autosourcing-stub"><p style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: normal; FONT-SIZE: 12px; PADDING-BOTTOM: 0px; MARGIN: 11px 0px 7px; PADDING-TOP: 0px; FONT-STYLE: normal; FONT-FAMILY: Dotum"><strong style="PADDING-RIGHT: 7px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">[출처]</strong> <a href="http://blog.naver.com/zerolive_/18271815" target="_blank">Dining philosopher</a><span style="PADDING-RIGHT: 7px; PADDING-LEFT: 5px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">|</span><strong style="PADDING-RIGHT: 7px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">작성자</strong> <a href="http://blog.naver.com/zerolive_" target="_blank">zerolive_</a></p></div>			 ]]> 
		</description>

		<comments>http://onredmusic.egloos.com/1735264#comments</comments>
		<pubDate>Tue, 27 May 2008 02:52:42 GMT</pubDate>
		<dc:creator>OnRedMusic</dc:creator>
	</item>
	<item>
		<title><![CDATA[ 제9회 한국자바개발자컨퍼런스 ]]> </title>
		<link>http://onredmusic.egloos.com/1409853</link>
		<guid>http://onredmusic.egloos.com/1409853</guid>
		<description>
			<![CDATA[ 
  <A href="http://jco.or.kr/" target=_new><IMG src="http://jco.or.kr/img/conference9th_jco.jpg"></A>			 ]]> 
		</description>

		<comments>http://onredmusic.egloos.com/1409853#comments</comments>
		<pubDate>Tue, 12 Feb 2008 16:26:18 GMT</pubDate>
		<dc:creator>OnRedMusic</dc:creator>
	</item>
	<item>
		<title><![CDATA[ ProgrammingRuby ]]> </title>
		<link>http://onredmusic.egloos.com/1257243</link>
		<guid>http://onredmusic.egloos.com/1257243</guid>
		<description>
			<![CDATA[ 
  <p><a href="http://www.ruby-doc.org/docs/ProgrammingRuby">http://www.ruby-doc.org/docs/ProgrammingRuby<br></a><a href="http://jacking75.cafe24.com/">http://jacking75.cafe24.com/<br></a></p>			 ]]> 
		</description>

		<comments>http://onredmusic.egloos.com/1257243#comments</comments>
		<pubDate>Tue, 08 Jan 2008 01:20:17 GMT</pubDate>
		<dc:creator>OnRedMusic</dc:creator>
	</item>
	<item>
		<title><![CDATA[ 수상인명구조원 ]]> </title>
		<link>http://onredmusic.egloos.com/1182776</link>
		<guid>http://onredmusic.egloos.com/1182776</guid>
		<description>
			<![CDATA[ 
  <p><div style="text-align:center"><img class="image_mid" border="0" onmouseover="this.style.cursor='pointer'" alt="" src="http://pds7.egloos.com/pds/200712/24/87/e0061187_476f6c57a37e0.jpg" width="500" height="363.125" onclick="Control.Modal.openDialog(this, event, 'http://pds7.egloos.com/pds/200712/24/87/e0061187_476f6c57a37e0.jpg');" /></div>ㅋㅋㅋㅋ<br><a href="http://daegu.redcross.or.kr/org/tem3/jisa_bbs/bbsview.jsp?JISA=03&amp;Seq=5038"><br><div style="text-align:center"><img class="image_mid" border="0" onmouseover="this.style.cursor='pointer'" alt="" src="http://pds6.egloos.com/pds/200712/28/87/e0061187_4774f5ec2127e.jpg" width="336" height="202" onclick="Control.Modal.openDialog(this, event, 'http://pds6.egloos.com/pds/200712/28/87/e0061187_4774f5ec2127e.jpg');" /></div><br>http://daegu.redcross.or.kr/org/tem3/jisa_bbs/bbsview.jsp?JISA=03&amp;Seq=5038</a><br><br>나한테 별~ 그다지 필요없는 자격증이지만 <br><br>언젠가 한번은 해보고 싶었던 막연했던 도전,<br>&nbsp;<br>더 나이 먹기전에 젊은 혈기 하나 믿고&nbsp;도전했다.<br><br>쉽게 딴 자격증이 아니기 때문에 이렇게 자랑은 할 수 있다.<br><br>다른 도전 또한 두렵지 않다. ㅋㅋ<br><br>P.S. 함께해준 07-8기 '팔공' 동기들에게 감사의 말을 전한다. 팔공! 화이팅~!<br><br><br><a href="http://daegu.redcross.or.kr/org/tem3/jisa_bbs/bbsview.jsp?JISA=03&amp;Seq=5038"><embed src="http://serviceapi.nmv.naver.com/flash/NFPlayer.swf?vid=8DFE4E9D6A7BA6F05F668A3E3473182783B4&amp;outKey=ca1069f087d472859b9c1641ff2f2bd31ba60cbd7d3cd935e2d9a1a4d8de36c963f4e918d87d502756cc46f53725b74b" width="500" height="408" type="application/x-shockwave-flash" wmode="transparent"></a></p><br/><br/>tag : <a href="/tag/라이프가드" rel="tag">라이프가드</a>,&nbsp;<a href="/tag/lifeguard" rel="tag">lifeguard</a>,&nbsp;<a href="/tag/수상인명구조" rel="tag">수상인명구조</a>,&nbsp;<a href="/tag/적십자" rel="tag">적십자</a>			 ]]> 
		</description>
		<category>Swim</category>
		<category>라이프가드</category>
		<category>lifeguard</category>
		<category>수상인명구조</category>
		<category>적십자</category>

		<comments>http://onredmusic.egloos.com/1182776#comments</comments>
		<pubDate>Mon, 24 Dec 2007 08:23:47 GMT</pubDate>
		<dc:creator>OnRedMusic</dc:creator>
	</item>
	<item>
		<title><![CDATA[ My Nubira ]]> </title>
		<link>http://onredmusic.egloos.com/1131352</link>
		<guid>http://onredmusic.egloos.com/1131352</guid>
		<description>
			<![CDATA[ 
  <div style="text-align:center"><img class="image_mid" border="0" onmouseover="this.style.cursor='pointer'" alt="" src="http://pds6.egloos.com/pds/200712/13/87/e0061187_4760e1f0edda0.jpg" width="500" height="375" onclick="Control.Modal.openDialog(this, event, 'http://pds6.egloos.com/pds/200712/13/87/e0061187_4760e1f0edda0.jpg');" /></div><div style="text-align:center"><img class="image_mid" border="0" onmouseover="this.style.cursor='pointer'" alt="" src="http://pds6.egloos.com/pds/200712/13/87/e0061187_4760de6b88597.jpg" width="500" height="375" onclick="Control.Modal.openDialog(this, event, 'http://pds6.egloos.com/pds/200712/13/87/e0061187_4760de6b88597.jpg');" /></div><div style="text-align:center"><img class="image_mid" border="0" onmouseover="this.style.cursor='pointer'" alt="" src="http://pds7.egloos.com/pds/200712/13/87/e0061187_4760de785bc1b.jpg" width="500" height="666.666666667" onclick="Control.Modal.openDialog(this, event, 'http://pds7.egloos.com/pds/200712/13/87/e0061187_4760de785bc1b.jpg');" /></div><div style="text-align:center"><img class="image_mid" border="0" onmouseover="this.style.cursor='pointer'" alt="" src="http://pds6.egloos.com/pds/200712/13/87/e0061187_4760df958a63a.jpg" width="500" height="375" onclick="Control.Modal.openDialog(this, event, 'http://pds6.egloos.com/pds/200712/13/87/e0061187_4760df958a63a.jpg');" /></div><div style="text-align:center"><img class="image_mid" border="0" onmouseover="this.style.cursor='pointer'" alt="" src="http://pds7.egloos.com/pds/200712/13/87/e0061187_4760dffcaada0.jpg" width="500" height="375" onclick="Control.Modal.openDialog(this, event, 'http://pds7.egloos.com/pds/200712/13/87/e0061187_4760dffcaada0.jpg');" /></div>주차 아저씨 죄송합니다.			 ]]> 
		</description>

		<comments>http://onredmusic.egloos.com/1131352#comments</comments>
		<pubDate>Thu, 13 Dec 2007 07:34:16 GMT</pubDate>
		<dc:creator>OnRedMusic</dc:creator>
	</item>
</channel>
</rss>
