e-zdy 0 Report post Posted September 7, 2005 hye leh sesaper bantu saya tak? saya tak pernah ada pengalaman mengune UNIX and tak beberape hebat dlm programming C++ programming C langsung tatau harap member putera dpt bantu saya dlm assignment saya...soklan nye beginiWrite two C/C++ programs (UNIX and WINDOWS programs) that create two child processes that are executed sequentially. One is to prints a greeting, sleeps for 20 seconds, and then exit. The other is to display the time and then exit. The parent process should print a greeting before creating the child to display the time. It should then terminate.The following UNIX and windows command could be used to create process. Fork(), exec(), createprocess().totally i have no idea ape yg diye nak..so sesaper leh bantu...tq Quote Share this post Link to post Share on other sites
electroboy 3 Report post Posted September 7, 2005 (edited) Maknanya dia suruh ko buat satu program parent dan dua program child (terpulang cara teknik apa yg ko nak gunakan).- salah satu child program tu keluarkan output message greetings, buat la apa2 greetings mengikut kegemaran ko, 'Hello World' ke apa. pastu sleep utk 20 saat dan terminate/exit.- satu lagi child program buat paparan waktu dan kemudian exit.Dan pastu ko buat satu parent program yg print greeting pastu display time. pastu terminate. dan ini mesti sequentially, atau consecutively, aku tak tau la perkataan melayu nak cakap camna. btw....Aku harap ko nampak dah idea camna nak buat program parent ni agar matlamat p&p lecturer ko tercapai.Dia bagi syarat lagi kena guna command Fork(), exec() dan createprocess() dlm membuat application tu.Dah faham apa yg kena buat? try buat sendiri dulu. Kalau sangkut di mana-mana, paste coding ko di sini, ramai pro di sini boleh tlg tengok-tengokkan. Edited September 7, 2005 by electroboy Quote Share this post Link to post Share on other sites
Ancient One 3 Report post Posted September 7, 2005 windows platformprocess ngan thread lain tau. kalau nak create 2 process baru yg tugasnya berlainan, maknanya u kena buat 3 program laa. satu parent, 2 lagi child tu. agaknya untuk tugas simple camni, guna thread dah memadai. Quote Share this post Link to post Share on other sites
1kHz 0 Report post Posted September 7, 2005 Dah soalan tu kena buat parent-child process, kena la ikut. Tapi betul gak kata Ancient One, pakai multithreading lebih ok..http://apache.hpi.uni-potsdam.de/document/..._Processes.htmlkalau tak tau apa soalan tu nak, rajin2 la berkunjung ke bilik lecturer... Quote Share this post Link to post Share on other sites
Ancient One 3 Report post Posted September 7, 2005 (edited) ye tak ye ek.. kena ikut cakap boss walaupun kiter betul .ni yg ringkas.. takde error handler. tambah sendirik :parent.c #include <windows.h> int main() { PROCESS_INFORMATION pi = {0}; STARTUPINFO si = {sizeof(si), 0}; TCHAR szChild1[] = "child1.exe"; TCHAR szChild2[] = "child2.exe"; CreateProcess(NULL, szChild1, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); Sleep(1000); WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); ZeroMemory(&pi, sizeof(pi)); ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); printf("PARENT :: Hello\n"); CreateProcess(NULL, szChild2, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); Sleep(1000); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); return 0; } child1.c #include <windows.h> int main() { printf("CHILD 1 :: Hello\n"); Sleep(20000); return 0; } child2.c #include <windows.h> int main() { SYSTEMTIME st; GetLocalTime(&st); printf("CHILD 2 :: Current Time - %.2u:%.2u:%.2u\n", (unsigned int)st.wHour, (unsigned int)st.wMinute, (unsigned int)st.wSecond); return 0; } edit silap tag daa.. Edited September 7, 2005 by Ancient One Quote Share this post Link to post Share on other sites
mohdfadly 24 Report post Posted September 7, 2005 * Topik ini dipindahkan ke C & C++ Quote Share this post Link to post Share on other sites
e-zdy 0 Report post Posted September 7, 2005 * Topik ini dipindahkan ke C & C++←aaaaaaa tq tq...aku tatau cemane ko leh include window.h....waaa aku blaja tak penah blaja c!! huhu aku rasa cam susah jer nak wat pogemin nie..yg reti flash itu pon sket2...ada tips tk nak asah sket pogemin nie.?? if there is good link...plz plz do plz...gimme thanks guys...about the linux i just learn it today...waa susah basic c takde...tp main buat je tadi... Quote Share this post Link to post Share on other sites
encik pot pet 0 Report post Posted September 7, 2005 baca ni dulu la cadangan saya ini - http://winprog.org/tutorial/ Quote Share this post Link to post Share on other sites
Ancient One 3 Report post Posted September 8, 2005 susahlaaa camni. Quote Share this post Link to post Share on other sites
e-zdy 0 Report post Posted September 8, 2005 susahlaaa camni.←mmg susah pon satu bende tak phm pasal c nih...nie file nie nak kene compile buat header file ker? kalau ada yg versi dos rasa lebey senang..sbb c++ pon aku gune dos....win nye tak penah gune... Quote Share this post Link to post Share on other sites
mohdfadly 24 Report post Posted September 8, 2005 Banyakkan membaca kod orang lain. Cuba sampai dapat, jangan give-up.Orang yg dah pengalaman kat dalam sini contohnya, semua habiskan masa depan komputer (tengok kod) sampai mata lebam-lebam.e-zdy punya mata camner? lebam tak? kalau blom lebam, kasi sampai lebam.. heheheh.. Quote Share this post Link to post Share on other sites
Ancient One 3 Report post Posted September 8, 2005 biasanya compiler yg khusus utk dos takleh compile kod untuk windows. kena carik cross-platform compiler laa.. guna windows nyer C++ compiler bleh laaa..try laa bacer buku pasal C dulu. Quote Share this post Link to post Share on other sites
encik pot pet 0 Report post Posted September 8, 2005 biasanya yg anda belajar programming c/c++ dalam kelas ialah platform independent dah boleh compile run kat mana2 compiler (kalau ikut standard la)tapi utk real programming task, platform tertentu banyak mempengaruhi program kita.cross-platform compiler, biasanya utk digunakan dalam GUI and platform independent task, selebihnya ada code yg berbeza utk platform masing2http://zephyrous.net/Programming_Windows_B...les_Petzold.chmhttp://zephyrous.net/Wrox.Press.-.Beginnin...tion.(2003).chm Quote Share this post Link to post Share on other sites
e-zdy 0 Report post Posted September 8, 2005 biasanya yg anda belajar programming c/c++ dalam kelas ialah platform independent dah boleh compile run kat mana2 compiler (kalau ikut standard la)tapi utk real programming task, platform tertentu banyak mempengaruhi program kita.cross-platform compiler, biasanya utk digunakan dalam GUI and platform independent task, selebihnya ada code yg berbeza utk platform masing2http://zephyrous.net/Programming_Windows_B...les_Petzold.chmhttp://zephyrous.net/Wrox.Press.-.Beginnin...tion.(2003).chm←kalau gune linux ada sesaper tau tak ape beze diye ngan coding kat ats tu?? aku tk penah pakai linux seumur hidup nie...nak buat program gune linux pon aku tak reti Quote Share this post Link to post Share on other sites
encik pot pet 0 Report post Posted September 8, 2005 pegi sub-forum linux http://forum.putera.com/tanya/index.php?showforum=16and tanya distro mana sesuai utk development dan yg paling penting, senang nak install/guna Quote Share this post Link to post Share on other sites
Ancient One 3 Report post Posted September 9, 2005 thats what you call API (Application Programming Interface). Windows ader Windows API. Install platform SDK dan u bleh start programming ngan C/C++. Biasanya u akan include windows.h laaa.. Linux.. bergantung laa.. tapi C library memang ader. Function fork() ngan exec() kat atas tu tak silap aku linux nyer syscall. kodnya lain lerr.. Quote Share this post Link to post Share on other sites