473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Parallel Programming with .NET

I came up with what I think is a good idea for making multithreading
programming easier in any .NET language. I dont know where else to post it,
so I'll try here.

..NET 2.0 adds the capability to write anonymous functions, it would be nice
if there was a "parallel" statement, that could simplify writing threadprocs.
e.g. (theoretical c#)
public void DoSomeParallelStuff() {
parallel
{
{
// do some network stuff
// this is an anonymous ThreadProc
}
{
// do some IO stuff
}
{
// do some DB stuff
}
}

// do other stuff, on caller thread
}
behind the scenes the compiler could create the anonymous functions, add
them to the ThreadPool by calling ThreadPool.QueueUserWorkItem. in some cases
it would be nice to automatically block the caller thread, maybe a sister
statement "parallel-blocked"
parrallel-blocked {
{
// read from drive c:
StreamReader rd = new StreamReader("C:\test.txt");
...
}
{
// read from drive d: (done in parallel)
StreamReader rd = new StreamReader("D:\test.txt");
...
}
}

// thread blocks until all parallel anonymous functions complete
Console.WriteLine("Tasks complete");

I think this would make it much easier to write multithreaded code. I've
actually added this feature to a compiler I'm working on and it works quite
nicely.

Jul 21 '05 #1
10 2236
Add the 'YouKnowWhatIMean' and 'HereAMiracleOccurs' while your'e at it.
"Joshua Nussbaum" <Joshua Nu******@discussions.microsoft.com> wrote in
message news:2B**********************************@microsof t.com...
I came up with what I think is a good idea for making multithreading
programming easier in any .NET language. I dont know where else to post
it,
so I'll try here.

.NET 2.0 adds the capability to write anonymous functions, it would be
nice
if there was a "parallel" statement, that could simplify writing
threadprocs.
e.g. (theoretical c#)
public void DoSomeParallelStuff() {
parallel
{
{
// do some network stuff
// this is an anonymous ThreadProc
}
{
// do some IO stuff
}
{
// do some DB stuff
}
}

// do other stuff, on caller thread
}
behind the scenes the compiler could create the anonymous functions, add
them to the ThreadPool by calling ThreadPool.QueueUserWorkItem. in some
cases
it would be nice to automatically block the caller thread, maybe a sister
statement "parallel-blocked"
parrallel-blocked {
{
// read from drive c:
StreamReader rd = new StreamReader("C:\test.txt");
...
}
{
// read from drive d: (done in parallel)
StreamReader rd = new StreamReader("D:\test.txt");
...
}
}

// thread blocks until all parallel anonymous functions complete
Console.WriteLine("Tasks complete");

I think this would make it much easier to write multithreaded code. I've
actually added this feature to a compiler I'm working on and it works
quite
nicely.

Jul 21 '05 #2
Not quite what you asked for but, if you go to
http://research.microsoft.com/resear...s/default.aspx and download
the bits for
"C# Software Transactional Memory" you will find some help for creating
parallel threaded systems.

MSR is very cool.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Joshua Nussbaum" <Joshua Nu******@discussions.microsoft.com> wrote in
message news:2B**********************************@microsof t.com...
I came up with what I think is a good idea for making multithreading
programming easier in any .NET language. I dont know where else to post
it,
so I'll try here.

.NET 2.0 adds the capability to write anonymous functions, it would be
nice
if there was a "parallel" statement, that could simplify writing
threadprocs.
e.g. (theoretical c#)
public void DoSomeParallelStuff() {
parallel
{
{
// do some network stuff
// this is an anonymous ThreadProc
}
{
// do some IO stuff
}
{
// do some DB stuff
}
}

// do other stuff, on caller thread
}
behind the scenes the compiler could create the anonymous functions, add
them to the ThreadPool by calling ThreadPool.QueueUserWorkItem. in some
cases
it would be nice to automatically block the caller thread, maybe a sister
statement "parallel-blocked"
parrallel-blocked {
{
// read from drive c:
StreamReader rd = new StreamReader("C:\test.txt");
...
}
{
// read from drive d: (done in parallel)
StreamReader rd = new StreamReader("D:\test.txt");
...
}
}

// thread blocks until all parallel anonymous functions complete
Console.WriteLine("Tasks complete");

I think this would make it much easier to write multithreaded code. I've
actually added this feature to a compiler I'm working on and it works
quite
nicely.

Jul 21 '05 #3
<=?Utf-8?B?Sm9zaHVhIE51c3NiYXVt?= <Joshua
Nu******@discussions.microsoft.com>> wrote:

<snip>
I think this would make it much easier to write multithreaded code. I've
actually added this feature to a compiler I'm working on and it works quite
nicely.


I don't know - I can't think of many situations where I've used
multithreading where it would be more readable than doing things more
explicitly.

I prefer the language to remain nice and small, not having much stuff
which is threading-specific. (Even "lock" would have been better to use
the "using" pattern, IMO.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
<=?Utf-8?B?Sm9zaHVhIE51c3NiYXVt?= <Joshua
Nu******@discussions.microsoft.com>> wrote:

<snip>
I think this would make it much easier to write multithreaded code. I've
actually added this feature to a compiler I'm working on and it works
quite
nicely.
I don't know - I can't think of many situations where I've used
multithreading where it would be more readable than doing things more
explicitly.

I prefer the language to remain nice and small, not having much stuff
which is threading-specific. (Even "lock" would have been better to use
the "using" pattern, IMO.)


While I tend to agree, I do see some value in allowing easy parallelization
of loops or over enumerations. However it certainly can be converted to an
API.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #5

"Joshua Nussbaum" <Joshua Nu******@discussions.microsoft.com> wrote in
message news:2B**********************************@microsof t.com...
I came up with what I think is a good idea for making multithreading
programming easier in any .NET language. I dont know where else to post
it,
so I'll try here.

.NET 2.0 adds the capability to write anonymous functions, it would be
nice
if there was a "parallel" statement, that could simplify writing
threadprocs.
e.g. (theoretical c#)

<snip examples>

What I have to ask is why would a compiler option be best here? Could you
not use 2.0 anonymous method and a simple api:

Parallel.NonBlockingExecute(
delegate { //do IO },
delegate {//do DB },
delegate {//do network },
)

or
Parallel.BlockingExecute(
delegate { //do IO },
delegate {//do DB },
delegate {//do network },
)

// thread blocks until all parallel anonymous functions complete
Console.WriteLine("Tasks complete");
I do see value in parallelization in the language(or a subset of it anyhow),
but not in this particular form. Permitting the runtime or language to
parallelize long running loops in a form that OpenMP permits would be
interesting, for example.

On other news, Its nice to see someone else working on a compiler. Are you
starting from scratch or basing off mono's?
Jul 21 '05 #6

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
<=?Utf-8?B?Sm9zaHVhIE51c3NiYXVt?= <Joshua
Nu******@discussions.microsoft.com>> wrote:

<snip>
I think this would make it much easier to write multithreaded code. I've
actually added this feature to a compiler I'm working on and it works
quite
nicely.
I don't know - I can't think of many situations where I've used
multithreading where it would be more readable than doing things more
explicitly.

I prefer the language to remain nice and small, not having much stuff
which is threading-specific. (Even "lock" would have been better to use
the "using" pattern, IMO.)


While I tend to agree, I do see some value in allowing easy parallelization
of loops or over enumerations. However it certainly can be converted to an
API.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #7

"Joshua Nussbaum" <Joshua Nu******@discussions.microsoft.com> wrote in
message news:2B**********************************@microsof t.com...
I came up with what I think is a good idea for making multithreading
programming easier in any .NET language. I dont know where else to post
it,
so I'll try here.

.NET 2.0 adds the capability to write anonymous functions, it would be
nice
if there was a "parallel" statement, that could simplify writing
threadprocs.
e.g. (theoretical c#)

<snip examples>

What I have to ask is why would a compiler option be best here? Could you
not use 2.0 anonymous method and a simple api:

Parallel.NonBlockingExecute(
delegate { //do IO },
delegate {//do DB },
delegate {//do network },
)

or
Parallel.BlockingExecute(
delegate { //do IO },
delegate {//do DB },
delegate {//do network },
)

// thread blocks until all parallel anonymous functions complete
Console.WriteLine("Tasks complete");
I do see value in parallelization in the language(or a subset of it anyhow),
but not in this particular form. Permitting the runtime or language to
parallelize long running loops in a form that OpenMP permits would be
interesting, for example.

On other news, Its nice to see someone else working on a compiler. Are you
starting from scratch or basing off mono's?
Jul 21 '05 #8
Thanks, that was helpful.

I actually started my compiler from scratch. its basically an XML syntax
for writing .NET programs. e.g.

<method name="Foo">
<parameters>
<parameter type="int" name="arg1"/>
</parameters>
<statements>
<if condition="arg1 == 22">
<statements>
<declare type="SomeClass" variable="obj" initializer="NEW SomeClass()"/>
<call expression="obj.CallMe()"/>
</statements>
</if>
</statements>
</method>

Because i'm using XML and I have an XML schema, half of the code validation
is done out of the box. So I beleive the mono compiler is overkill for this
project. (though my compiler should be able to run on the mono clr)

The idea isnt to hand code applications in XML, that would be very tedious.
So I'm also working on an IDE for writing code completely visually.

Avalon and 3D interfaces are coming, and I think it can help IDE technology
too.

"Daniel O'Connell [C# MVP]" wrote:

"Joshua Nussbaum" <Joshua Nu******@discussions.microsoft.com> wrote in
message news:2B**********************************@microsof t.com...
I came up with what I think is a good idea for making multithreading
programming easier in any .NET language. I dont know where else to post
it,
so I'll try here.

.NET 2.0 adds the capability to write anonymous functions, it would be
nice
if there was a "parallel" statement, that could simplify writing
threadprocs.
e.g. (theoretical c#)

<snip examples>

What I have to ask is why would a compiler option be best here? Could you
not use 2.0 anonymous method and a simple api:

Parallel.NonBlockingExecute(
delegate { //do IO },
delegate {//do DB },
delegate {//do network },
)

or
Parallel.BlockingExecute(
delegate { //do IO },
delegate {//do DB },
delegate {//do network },
)

// thread blocks until all parallel anonymous functions complete
Console.WriteLine("Tasks complete");
I do see value in parallelization in the language(or a subset of it anyhow),
but not in this particular form. Permitting the runtime or language to
parallelize long running loops in a form that OpenMP permits would be
interesting, for example.

On other news, Its nice to see someone else working on a compiler. Are you
starting from scratch or basing off mono's?

Jul 21 '05 #9
Thanks, that was helpful.

I actually started my compiler from scratch. its basically an XML syntax
for writing .NET programs. e.g.

<method name="Foo">
<parameters>
<parameter type="int" name="arg1"/>
</parameters>
<statements>
<if condition="arg1 == 22">
<statements>
<declare type="SomeClass" variable="obj" initializer="NEW SomeClass()"/>
<call expression="obj.CallMe()"/>
</statements>
</if>
</statements>
</method>

Because i'm using XML and I have an XML schema, half of the code validation
is done out of the box. So I beleive the mono compiler is overkill for this
project. (though my compiler should be able to run on the mono clr)

The idea isnt to hand code applications in XML, that would be very tedious.
So I'm also working on an IDE for writing code completely visually.

Avalon and 3D interfaces are coming, and I think it can help IDE technology
too.

"Daniel O'Connell [C# MVP]" wrote:

"Joshua Nussbaum" <Joshua Nu******@discussions.microsoft.com> wrote in
message news:2B**********************************@microsof t.com...
I came up with what I think is a good idea for making multithreading
programming easier in any .NET language. I dont know where else to post
it,
so I'll try here.

.NET 2.0 adds the capability to write anonymous functions, it would be
nice
if there was a "parallel" statement, that could simplify writing
threadprocs.
e.g. (theoretical c#)

<snip examples>

What I have to ask is why would a compiler option be best here? Could you
not use 2.0 anonymous method and a simple api:

Parallel.NonBlockingExecute(
delegate { //do IO },
delegate {//do DB },
delegate {//do network },
)

or
Parallel.BlockingExecute(
delegate { //do IO },
delegate {//do DB },
delegate {//do network },
)

// thread blocks until all parallel anonymous functions complete
Console.WriteLine("Tasks complete");
I do see value in parallelization in the language(or a subset of it anyhow),
but not in this particular form. Permitting the runtime or language to
parallelize long running loops in a form that OpenMP permits would be
interesting, for example.

On other news, Its nice to see someone else working on a compiler. Are you
starting from scratch or basing off mono's?

Jul 21 '05 #10

"Josh Nussbaum" <Josh Nu******@discussions.microsoft.com> wrote in message
news:CA**********************************@microsof t.com...
Thanks, that was helpful.

I actually started my compiler from scratch. its basically an XML syntax
for writing .NET programs. e.g.

<method name="Foo">
<parameters>
<parameter type="int" name="arg1"/>
</parameters>
<statements>
<if condition="arg1 == 22">
<statements>
<declare type="SomeClass" variable="obj" initializer="NEW SomeClass()"/>
<call expression="obj.CallMe()"/>
</statements>
</if>
</statements>
</method>

Because i'm using XML and I have an XML schema, half of the code
validation
is done out of the box. So I beleive the mono compiler is overkill for
this
project. (though my compiler should be able to run on the mono clr)


Ahh, I see. I thought you meant a C# compiler, ;).

Interesting idea, good luck on it.

Jul 21 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Yuancai \(Charlie\) Ye | last post by:
Hi, All: I am happy to annouce that we have formally released our latest SocketPro version 4 at www.udaparts.com, an advanced remoting framework written from batching/queue, asynchrony and...
10
by: bpontius | last post by:
The GES Algorithm A Surprisingly Simple Algorithm for Parallel Pattern Matching "Partially because the best algorithms presented in the literature are difficult to understand and to implement,...
3
by: paytam | last post by:
Hi all, Is it possible to write parallel programming in C? I mean for example a simple program like I have a clock on a program that show me current time and and at the same time another job like...
126
by: ramyach | last post by:
Hi friends, I need to write a parallel code in 'C' on the server that is running SGI Irix 6.5. This server supports MIPS Pro C compiler. I don't have any idea of parallel C languages. I looked...
7
by: Joshua Nussbaum | last post by:
I came up with what I think is a good idea for making multithreading programming easier in any .NET language. I dont know where else to post it, so I'll try here. ..NET 2.0 adds the capability...
0
by: fiepye | last post by:
Hello. I am interested in parallel computing in Python. Except other modulesI would like to use new modules for vector and matrix operations and scientific computing SciPy and NumPy. I have...
26
by: Prime Mover | last post by:
Hello all, I have got the pseudo-code below that I would like to convert to c language. The algorithm calculates Pi value. I am somewhat familiar with C language, but I am just starting to learn...
3
by: John | last post by:
I have a program that needs to run on a regular basis that looks at a queue table in my database. If there are items in the queue database I need to grab the data from the database and pass it to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.