Category : C Source Code
Archive   : CSWITCH.ZIP
Filename : MT.C
Output of file : MT.C contained in archive : CSWITCH.ZIP
#include "dos.h"
#include "tcb.h"
extern int tcblist[];
extern int readyq[];
extern int swap_count;
extern int idlecount;
extern int noswap;
extern int mustswap;
extern int findlargemem();
int lines_read;
char msgbuf[1024];
extern void relinq();
int sem4test();
int readfile();
main()
{
union REGS ir;
unsigned int j,k;
long lj;
k=0;
puts("Multitasking test.");
start_mt();
j=findlargemem();
lj=(long)j * 16L;
printf("%ld bytes available\n",lj);
puts("waiting for semaphore to be set ");
spawn(sem4test,4);
while(sem_test(1)==-1) relinq();
sem_attach(1);
sem_release(1);
puts("got semaphore #1");
spawn(readfile,4);
for(;;) {
printf("Loop = %d idle=%d swap=%d read=%d\n",
k++,idlecount,swap_count, lines_read);
if(kbhit()) break;
if(testmsg(1)) {
recvmsg(1,msgbuf,1000);
puts(msgbuf);
}
}
end_mt();
getch();
}
sem4test()
{
int j,k,n;
union REGS ir;
sem_attach(1);
sleep(3);
sem_release(1);
spawn_exit();
}
readfile()
{
FILE *fp;
char buf[120];
union REGS ir;
int j;
fp=fopen("mt.c","r");
for(;;) {
if(fgets(buf,80,fp)==NULL) break;
lines_read++;
relinq();
}
send_md_msg(1,"\n\n\n\nWere done now\n\n\n", 24);
fclose(fp);
lines_read+=1000;
spawn_exit();
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/