By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

migration single processor to dual processor problem with threadin

P: n/a
Hello,

I have an application, that has been running on a single processor server
for more then a year without any problems. Now I'm migrating to a dual
processor server, and I'm experiencing problems with threading.

The application is actually a kind of job schedular. For all jobs, I can set
a recurring interval (daily,weekly, monthly etc) at which the specific job
should be started. We program each job, according to an interface. Examples
of jobs are: server monitoring, reporting, messaging etc.

The job itself maintains a status. When it's complete, it's status is set to
ready.

The job-schedular looks at certain times for two things: Should I start a
new job and Is there a job with status Ready which should be stopped.

the code for stopping a job is only a:
ji.InstanceThread.Abort();
ji.InstanceThread.Join(1000);
MJSJobList._jobList.Remove(ji);
What I now see, is that on the single processor server, this works, and the
job is removed from the list.
On the dual-processor server, however the job remains in the list with
status "Ready"..

Am I missing somethinge here ? The code worked perfectly on the other server
for a very long time.

Thanks in advance,
Michel Meex
Jun 2 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Michel,

Can you provide a more complete snipet of code? It's too difficult to
say what might be happening based only on 3 lines.

Brian

Michel Meex wrote:
Hello,

I have an application, that has been running on a single processor server
for more then a year without any problems. Now I'm migrating to a dual
processor server, and I'm experiencing problems with threading.

The application is actually a kind of job schedular. For all jobs, I can set
a recurring interval (daily,weekly, monthly etc) at which the specific job
should be started. We program each job, according to an interface. Examples
of jobs are: server monitoring, reporting, messaging etc.

The job itself maintains a status. When it's complete, it's status is set to
ready.

The job-schedular looks at certain times for two things: Should I start a
new job and Is there a job with status Ready which should be stopped.

the code for stopping a job is only a:
ji.InstanceThread.Abort();
ji.InstanceThread.Join(1000);
MJSJobList._jobList.Remove(ji);
What I now see, is that on the single processor server, this works, and the
job is removed from the list.
On the dual-processor server, however the job remains in the list with
status "Ready"..

Am I missing somethinge here ? The code worked perfectly on the other server
for a very long time.

Thanks in advance,
Michel Meex


Jun 2 '06 #2

P: n/a
Agreed. Not much to go on.

As a wild stab in the dark I would point out that any resource that is
accessed from more than one thread should really be marked as volatile. This
effectively says, don't get this from processor cached memory, do a read
from system memory. It is especially important to consider this in mult-proc
enviroments as your threads may end up executing on different chips.

In this case apply volatile to _jobList in MJSJobList.
"Brian Gideon" <br*********@yahoo.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
Michel,

Can you provide a more complete snipet of code? It's too difficult to
say what might be happening based only on 3 lines.

Brian

Michel Meex wrote:
Hello,

I have an application, that has been running on a single processor server
for more then a year without any problems. Now I'm migrating to a dual
processor server, and I'm experiencing problems with threading.

The application is actually a kind of job schedular. For all jobs, I can
set
a recurring interval (daily,weekly, monthly etc) at which the specific
job
should be started. We program each job, according to an interface.
Examples
of jobs are: server monitoring, reporting, messaging etc.

The job itself maintains a status. When it's complete, it's status is set
to
ready.

The job-schedular looks at certain times for two things: Should I start a
new job and Is there a job with status Ready which should be stopped.

the code for stopping a job is only a:
ji.InstanceThread.Abort();
ji.InstanceThread.Join(1000);
MJSJobList._jobList.Remove(ji);
What I now see, is that on the single processor server, this works, and
the
job is removed from the list.
On the dual-processor server, however the job remains in the list with
status "Ready"..

Am I missing somethinge here ? The code worked perfectly on the other
server
for a very long time.

Thanks in advance,
Michel Meex

Jun 3 '06 #3

P: n/a
Ok, here's some more code.

In the windows service, a timer executes the following method:
internal void MonitorJobs()
{
ArrayList al = this.RetrieveJobsState();
foreach(MJSJobState js in al)
{
//If job is ready
if (js.JobState == MJSJobStatic.JobState.Ready)
{
TempLogging(js.JobName,"Job found, status ready, should stop");
bool _found = false;
//stop and clear job
foreach (MJSJobInstance ji in MJSJobList._jobList)
{
if (ji.JobData.JobName == js.JobName)
{
_found = true;
this.JobStop(ji.JobData);
break; }
}
TempLogging(js.JobName,"Job found: " + _found.ToString());
}
}
}

the method JobStop contains the following:
public void JobStop(MJSJobData jobData)
{
if (jobData != null)
{
//if job is running
if (this.JobIsRunning(jobData) ==
MJSJobStatic.ThreeValueBool.True)
{
bool jobStopped = false;
//Find job instance in joblist
foreach (MJSJobInstance ji in MJSJobList._jobList)
{
if (jobData != null)
{
if (jobData.JobName == ji.JobData.JobName)
{
//Call job stop method (IJob interface),
((IJob) ji.InstanceObject).Stop();
//Clear object reference
ji.InstanceObject = null;
//Stop process / end thread
ji.InstanceThread.Abort();
ji.InstanceThread.Join(1000);

//debugging info
HistoryData _tempHistoryNew = new HistoryData();
_tempHistoryNew.JobName = ji.JobData.JobName;
_tempHistoryNew.Type = MJSJobStatic.HistoryType.Information;
_tempHistoryNew.Time = System.DateTime.Now;
_tempHistoryNew.Extra = "trying to stop.....debug info";
JobHistory.Add(_tempHistoryNew);
//end debugging info

//Remove job from JobList
MJSJobList._jobList.Remove(ji);
jobStopped = true;
break;
}
}
}

if (jobStopped)
{
//Log event
HistoryData _tempHistoryNew = new HistoryData();
_tempHistoryNew.JobName = jobData.JobName;
_tempHistoryNew.Type = MJSJobStatic.HistoryType.Information;
_tempHistoryNew.Time = System.DateTime.Now;
_tempHistoryNew.Extra = JOB_STOPPED;
JobHistory.Add(_tempHistoryNew);
}
else
{
//Log event
HistoryData _tempHistoryNew = new HistoryData();
_tempHistoryNew.JobName = jobData.JobName;
_tempHistoryNew.Type = MJSJobStatic.HistoryType.Error;
_tempHistoryNew.Time = System.DateTime.Now;
_tempHistoryNew.Extra = "Job could not be stopped.";
JobHistory.Add(_tempHistoryNew);
}
}
else
{
//Write something to the log
//Log event
HistoryData _tempHistoryNew = new HistoryData();
_tempHistoryNew.JobName = jobData.JobName;
_tempHistoryNew.Type = MJSJobStatic.HistoryType.Error;
_tempHistoryNew.Time = System.DateTime.Now;
_tempHistoryNew.Extra = "Job could not be stopped. The job is not
running.";
JobHistory.Add(_tempHistoryNew);
}
}
else
{
//Write something to the log if running state of job could not be
determined
//Log event
HistoryData _tempHistoryNew = new HistoryData();
_tempHistoryNew.JobName = string.Empty;
_tempHistoryNew.Type = MJSJobStatic.HistoryType.Error;
_tempHistoryNew.Time = System.DateTime.Now;
_tempHistoryNew.Extra = "Job could not be stopped. No job provided.";
JobHistory.Add(_tempHistoryNew);
}
}

I hope you can do something with this..
Regards,
Michel
Jun 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.